Go to advanced search

by gordon@drogon.net
Wed Nov 15, 2017 3:13 pm
Forum: C/C++
Topic: Help with ILI9225 display
Replies: 3
Views: 186

Re: Help with ILI9225 display

Two things - firstly I'd try one screen with the hardware SPI, then if that works, then you can use all 4 with the hardware SPI by using alternative CE pins and manually setting those pins rather than let the hardware use the hardware CE pins. (I do this to let me run 3 SPI Thermocouple amplifiers o...
by gordon@drogon.net
Mon Nov 13, 2017 4:49 pm
Forum: C/C++
Topic: C code for MCP3008
Replies: 19
Views: 14833

Re: C code for MCP3008

I run raspi-config as sudo and enabled SPI and disabled I2C. Then I tried the command gpio load spi, but got these error: gpio: Unable to load/unload modules as this Pi has the device tree enabled. You need to run the raspi-config program (as root) and select the modules (SPI or I2C) that you wish ...
by gordon@drogon.net
Mon Nov 13, 2017 4:34 pm
Forum: C/C++
Topic: C code for MCP3008
Replies: 19
Views: 14833

Re: C code for MCP3008

Hello Gordon, thank you for your reply. These are the values of the variables: class PotController { private: //BASE is a new pin base for the chip of the analog pins const int MCP3008_BASE = 100; // chose the SPI_channel const int MCP3008_SPI_CHAN = 0; I tried the command but I received the follow...
by gordon@drogon.net
Mon Nov 13, 2017 11:11 am
Forum: C/C++
Topic: [done] Starting with C++
Replies: 6
Views: 412

Re: Starting with C++

I double that: Too poor code examples for C to beginners available in complete tutorials, compared to Arduino or Python/Pi ! about temperature and humidity, what about that: http://www.uugear.com/portfolio/dht11-humidity-temperature-sensor-module/ /* * dht11.c: * Simple test program to test the wir...
by gordon@drogon.net
Mon Nov 13, 2017 11:05 am
Forum: C/C++
Topic: C code for MCP3008
Replies: 19
Views: 14833

Re: C code for MCP3008

I have tried to use wiringPi for a MCP3008 and Potentiometer like abouve, but I did not get any value. ... wiringPiSetupGpio (); ... mcp3004Setup(this->MCP3008_BASE, this->MCP3008_SPI_CHAN) ; // 3004 and 3008 are the same 4/8 channels ... int value = analogRead(this->MCP3008_BASE); ... Don't know h...
by gordon@drogon.net
Fri Nov 10, 2017 6:33 am
Forum: C/C++
Topic: Audio stream to GPIO with custom filter
Replies: 6
Views: 388

Re: Audio stream to GPIO with custom filter

Hi, Going back to a basic example I am getting errors. Here is my simple program to read a prewritten PWM stream and the complete terminal session. At the end of the session I am getting undefined reference to errors. I get the same error with blink.c. I am on Ubuntu. Thanks in advance I'm sorry to...
by gordon@drogon.net
Thu Nov 09, 2017 4:34 pm
Forum: C/C++
Topic: Audio stream to GPIO with custom filter
Replies: 6
Views: 388

Re: Audio stream to GPIO with custom filter

Hi again, I have the file opening, upsampling, custom filter and custom conversion for a GPIO format working well in JUCE on the PI. File chooser and format could be built in minutes in JUCE. I have also built a DAC circuit to connect to the GPIO. I am having trouble getting simple digital read and...
by gordon@drogon.net
Tue Nov 07, 2017 1:04 pm
Forum: C/C++
Topic: Reading GPIO pin
Replies: 2
Views: 321

Re: Reading GPIO pin

Did you test the hardware before jumping into code? If you did, then ignore this, but if not, then type this into a terminal: gpio -g mode 21 in while true; do echo -n `gpio -g read 21` ; done Then set/clear the input signal and make sure you get what you expect. Then debug the code. -Gordon
by gordon@drogon.net
Sun Oct 29, 2017 10:38 pm
Forum: C/C++
Topic: WiringPi removing SDcard gcc compiler code::blocks
Replies: 1
Views: 270

Re: WiringPi removing SDcard gcc compiler code::blocks

Are you absolutely sure you are running it as root? Currently if you try to use PWM without being root you will experience odd issues - like the SD card becoming offline.

wiringPi currently does not check for the pwm case requiring root.

-Gordon
by gordon@drogon.net
Fri Oct 13, 2017 5:09 pm
Forum: C/C++
Topic: WiringPi Serial help
Replies: 8
Views: 608

Re: WiringPi Serial help

Hi 1dot0, thank you for the reply. 1) if it can never be -1, what then should i put instead? Well - firstly you ought to use CODE tags round the code - it makes it easier for people to read. then you need to start reading the fine manuals where it tells you what the return code is - it's an integer...
by gordon@drogon.net
Fri Oct 13, 2017 1:56 pm
Forum: C/C++
Topic: WiringPi Serial help
Replies: 8
Views: 608

Re: WiringPi Serial help

you should check the return code from serialOpen(), however that's not your issue - the issue is that output is buffered until you print a new line, so either append a newline \n to the printf() or call fflush (stdout); after the printf() call.

-Gordon
by gordon@drogon.net
Mon Oct 02, 2017 8:58 am
Forum: Other languages
Topic: Porting ARM BASIC to the Raspberry Pi via SDL 2.0
Replies: 89
Views: 11272

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Having checked out the data file input capabilities of both RTB and FUZE Basic [sic], I found that it seems they are not really capable of reading binary data which would appear in an image file. Just as I was determining that RTB and FUZE Basic [sic] would not likely be able to serve my needs, I d...
by gordon@drogon.net
Sun Oct 01, 2017 11:25 am
Forum: C/C++
Topic: Closing serial port when doing ^C
Replies: 4
Views: 695

Re: Closing serial port when doing ^C

I'm somewhat confused here - when you ^C a program, all files are automatically closed. This includes things like serial ports. You can not normally leave files open when your program terminates. So it sounds like something else is going on. When serialOpen() returns -1, then errno will be set - it ...
by gordon@drogon.net
Tue Sep 26, 2017 2:23 pm
Forum: C/C++
Topic: Serial Port RAW mode
Replies: 5
Views: 630

Re: Serial Port RAW mode

Code: Select all

#include <wiringSerial.h>

...

  fd = serialOpen ("/dev/ttyUSB0", 115200) ;
  ...
  while (serialDataAvail (fd))
  {
  ... do stuff, etc.
  }
From the "make life easy for you" department.
-Gordon
by gordon@drogon.net
Wed Sep 20, 2017 8:56 am
Forum: C/C++
Topic: Simple GPIO access in C
Replies: 25
Views: 22206

Re: Simple GPIO access in C

One if the issues using your own hardware poking is that you need to be aware of a few things - and one is that the hardware address is not the same over all Pi models. It changed. That's one reason to use someone elses library - they all detect the change for you. e.g. using wiringPi, #include <wir...
by gordon@drogon.net
Thu Sep 14, 2017 1:15 pm
Forum: C/C++
Topic: Unable to read Pi input
Replies: 3
Views: 339

Re: Unable to read Pi input

Hi everyone, So I am trying to read in the state of a PWM MA3 absolute rotary encoder with the Raspberry Pi. When I run the code below, only values of zero are being printed. When I run the Python equivalent code, I get a series of ones and zeros, so I'm not sure what I am doing wrong with the C co...
by gordon@drogon.net
Wed Sep 13, 2017 2:31 pm
Forum: C/C++
Topic: GPIO: should I learn sysfs or direct register access?
Replies: 3
Views: 459

Re: GPIO: should I learn sysfs or direct register access?

Make life easy for yourself and use a library - there are a couple to choose from. wiringPi (mine) and PiGPIO are the popular ones. both include command-line tools to let you do stuff without even writing a program. e.g. in wiringPi - blink an LED on physical pin 11: gpio -1 blink 11 (the -1 tells i...
by gordon@drogon.net
Wed Aug 16, 2017 10:03 am
Forum: General programming discussion
Topic: Not able to turn a pin to be zero
Replies: 3
Views: 508

Re: Not able to turn a pin to be zero

If you are using the Kernel SPI driver (either directly or via the wiringPi helpers, or some other library) then you should not. ever. touch the pins directly with pinMode(), exports, digitalWrite(), etc. Leave them to the kernel. Don't even read the pin states as it's of no-use to you whatsoever. E...
by gordon@drogon.net
Thu Aug 10, 2017 8:58 pm
Forum: C/C++
Topic: Sampling with C and MCP3008
Replies: 8
Views: 933

Re: Sampling with C and MCP3008

There are several strategies - however the Linux thing might be more a limitation - remember the Pi is running a multi-user, multi-tasking operating system - it's not a microcontroller running your dedicated code and nothing else.... For for fixed rate sampling, one strategy is to calculate the next...
by gordon@drogon.net
Thu Aug 10, 2017 8:48 pm
Forum: C/C++
Topic: I2C LCD Display Library
Replies: 19
Views: 1649

Re: I2C LCD Display Library

you might want to look at wiringPi - if your display is one of the usual ones with the hitachi or compatible display. http://wiringpi.com/dev-lib/lcd-library/ The way to use this via an I2C GPIO expander is to first include the expander into wiringPi's pin system, then work out the pins to use in yo...
by gordon@drogon.net
Sun Aug 06, 2017 11:20 am
Forum: C/C++
Topic: Error linking lib wiringPi
Replies: 13
Views: 1272

Re: Error linking lib wiringPi

PeterO -> I'm using the command the example give : gcc -Wall -o blink blink.c -lwiringPi Gordon -> I'm running on Raspbian. I was working some years ago with RPIO and PMW to run a motor. But with the time, the lib seems to be not maintained anymore so I cannot continue my work with it. So I searche...
by gordon@drogon.net
Mon Jul 31, 2017 12:47 pm
Forum: C/C++
Topic: Error linking lib wiringPi
Replies: 13
Views: 1272

Re: Error linking lib wiringPi

I got an error trying to run a small example program find on wiringPi website ( http://wiringpi.com/examples/blink/ ). No error occured during installation of the lib. Here the error : /usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/crt1.o: In function `_start': /build/glibc-P1SmL...
by gordon@drogon.net
Sun Jul 30, 2017 9:20 pm
Forum: C/C++
Topic: MCP23S17, Wiringpi or another library
Replies: 14
Views: 1026

Re: MCP23S17, Wiringpi or another library

  OK, thanks, I understand. Then after config both MCP in same program, I access to status of each pin with the base1 and base2 fields ? Do not understand yet how work this of BASE field when setup MCP. I see one example where assign #define BASE 123, and seem that access to each pin with BASE + pi...
by gordon@drogon.net
Sat Jul 29, 2017 6:16 pm
Forum: C/C++
Topic: MCP23S17, Wiringpi or another library
Replies: 14
Views: 1026

Re: MCP23S17, Wiringpi or another library

wiringPi can handle 16 mcp12s17's on the standard SPI port on a Raspberry Pi. I'm not seeing where your issue is. In mcp23s17Setup(), there are 3 parameters: pinBase, spiPort and devId. The pinBase is the new pin number of the first pin of the device - any number >= 64 that you like. The spiPort is ...
by gordon@drogon.net
Mon Jul 24, 2017 8:40 am
Forum: C/C++
Topic: DHT22 and mcp3208 has crash?
Replies: 1
Views: 287

Re: DHT22 and mcp3208 has crash?

Not sure what you're doing however, just a few FIY's: wiringPiSetup() will always return TRUE, or it will halt your program. There is no point checking for a return code. See http://wiringpi.com/reference/setup/ wiringPi supports the mcp3008 - it's the mcp3004 driver, just: #include <mcp3004.h> ... ...

Go to advanced search