led.c (Gertboard_sw_20130106.zip) & buf6 led(gpio18) Solved


9 posts
by blachanc » Fri Feb 15, 2013 4:03 pm
hi,
I will post a waveform later(at work now), but when I run led.c, my buf6(gpio18) led is not following the sequence
it will only lit when all other led are being lit.
The buf 6 signal also shows hi to low glitches.

I am using:
raspian( the version just before the last one, but up to date)(note1)
assembled Gertboard.
Pi rev 2, but cpuinfo claims if is rev F...

regards
Ben
note1: I could not find a release note history of raspian releases
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191
User avatar
Posts: 259
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)
by gordon@drogon.net » Sat Feb 16, 2013 2:17 pm
blachanc wrote:hi,
I will post a waveform later(at work now), but when I run led.c, my buf6(gpio18) led is not following the sequence
it will only lit when all other led are being lit.
The buf 6 signal also shows hi to low glitches.

I am using:
raspian( the version just before the last one, but up to date)(note1)
assembled Gertboard.
Pi rev 2, but cpuinfo claims if is rev F...

regards
Ben
note1: I could not find a release note history of raspian releases


The software version of Raspbian is unlikely to be an issue - and board revision 000f is fine - that's a Rev 2 board.

Check the buffer direction jumpers - make sure they're set to output for the pins you're using - remember - away from the Pi is outputs and towards the Pi is inputs...

Personally, I'd fetch wiringPi and try it out from the command-line one LED at a time:

Code: Select all
gpio -g mode 18 out
gpio -g write 18 0 # LED off
gpio -g write 18 1 # LED on


might get you going, but double check the wiring, etc.

Get wiringPi by:

Code: Select all
cd ; git clone git://git.drogon.net/wiringPi ; cd wiringPi ; ./build


I'm in the process of making a whole series on using the Gertboard with wiringPi for C programs too, but it's still a work in progress, however you can sneak a look here: https://projects.drogon.net/raspberry-p ... -wiringpi/

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1537
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by blachanc » Sat Feb 16, 2013 7:48 pm
Hi Gordon,

Thank you for your proposition.

I will try and update the wiringPI, and run manual tests.
I am attaching the waveform I captured two days ago so you can see what I mean.
The analog probe is on BUF6...

Regards,

Benoit
Attachments
BUF6_led.gif
leds.c scope trace
BUF6_led.gif (16.55 KiB) Viewed 940 times
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191
User avatar
Posts: 259
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)
by gordon@drogon.net » Sat Feb 16, 2013 8:16 pm
blachanc wrote:Hi Gordon,

Thank you for your proposition.

I will try and update the wiringPI, and run manual tests.
I am attaching the waveform I captured two days ago so you can see what I mean.
The analog probe is on BUF6...

Regards,

Benoit


I've just refreshed my memory on Gerts leds.c program.

Firstly, have you read the program? Are you sure it's not doing what its supposed to do? At a quick glance I think it might be...

And those "glitches" may actually be as intended - check the program. What leds.c does is turn all LEDs off, then turns on the ones that need to be on - so if an LED is already on, it will be briefly (< 1uS) turned off, then on again. This isn't ideal, (for e.g. interfacing to some external logic), but it makes the program easier to write and no-one notices unless you hook up a logic analyser...

There are also 3 patterns in that program too - it will run each pattern twice before moving onto the next pattern.

Also if you have a Rev 2 Pi, then one LED will be missing too - change the 21 on line 47 into 27.

Also make sure you don't have the SPI module loaded.

If you have it wired up as that example suggests - ie. a 1:1 wiring from J2 to J3, then this should give the same sequence as the 3rd sequence in Gerts program - ie. lturn the LEDs on once by one, from left to right, then turn them off again (from left to right).

Code: Select all
#!/bin/bash

leds="25 24 23 22 27 18 17 11 10 9 8 7"

for led in $leds; do
  gpio -g mode $led out
done

while true; do
  for led in $leds; do
    gpio -g write $led 1
    sleep 0.5
  done

  for led in $leds; do
    gpio -g write $led 0
    sleep 0.5
  done
done


Save that as test.sh and run it with

Code: Select all
bash test.sh


(this is for a Rev 2 board which you have - anyone with aRev 1 Pi can change the 27 into 21 above)

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1537
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by blachanc » Sun Feb 17, 2013 6:17 am
Hi Gordon,
Thank you for your support, I really appreciate it.

using your script, LED6 really acted like if it had a mind of is own.... until I disabled SPI.... & REBOOTED...

USER PID %CPU %MEM SZ RSS TT STAT START TIME COMMAND
root 215 0.0 0.0 0 0 ? S< Feb16 0:00 [bcm2708_spi.0]
sudo leafpad /etc/modprobe.d/raspi-blacklist.conf
# blacklist spi and i2c by default (many users don't need them)

blacklist spi-bcm2708
blacklist i2c-bcm2708

now LED6 seems to follow the sequence but when LED5 is being turned off, LED6 also is being turned off.
It does the same using the command line gpio command.

I believe I will stay away from GP17 & GP18 for now.
The background of this thread:
20 years ago, I bought a phone keyboard: 4 rows, 3 cols addressing, and as a first exercise, I am trying to decode it using GPIO.
It should be trivial, but not when SPI is activated :lol: .

Regards,

Benoit
Attachments
NO_SPI.jpg
no_spi_trace
NO_SPI.jpg (45.24 KiB) Viewed 914 times
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191
User avatar
Posts: 259
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)
by gordon@drogon.net » Sun Feb 17, 2013 10:33 am
blachanc wrote:Hi Gordon,
Thank you for your support, I really appreciate it.

using your script, LED6 really acted like if it had a mind of is own.... until I disabled SPI.... & REBOOTED...

USER PID %CPU %MEM SZ RSS TT STAT START TIME COMMAND
root 215 0.0 0.0 0 0 ? S< Feb16 0:00 [bcm2708_spi.0]
sudo leafpad /etc/modprobe.d/raspi-blacklist.conf
# blacklist spi and i2c by default (many users don't need them)

blacklist spi-bcm2708
blacklist i2c-bcm2708

now LED6 seems to follow the sequence but when LED5 is being turned off, LED6 also is being turned off.
It does the same using the command line gpio command.

I believe I will stay away from GP17 & GP18 for now.
The background of this thread:
20 years ago, I bought a phone keyboard: 4 rows, 3 cols addressing, and as a first exercise, I am trying to decode it using GPIO.
It should be trivial, but not when SPI is activated :lol: .

Regards,

Benoit


What distro are you running? Raspbian (the one I'd recommend - also the current recommendted one by the foundation IIRC) normally has the SPI (& I2C) modules blacklisted by default...

However, that would not affect the first 8 GPIOs - 17,18, etc.

I'd be tempted now to go back to first principles and see if the board is properly functioning.

I'd test the LEDs by wiring them (the BUF pins) to 0v then to 3.3v, then use one pin from the Pi and test that, then test the others, one at a time. It's tedious, but it might find a short or some other issue.

Your phone keypad is probably a simple 4x3 matrix. They're not that complicated - I had one on my BBC Micro connected to the user port onceuponatime...

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1537
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by blachanc » Sun Feb 17, 2013 5:28 pm
What distro are you running? Raspbian (the one I'd recommend - also the current recommendted one by the foundation IIRC) normally has the SPI (& I2C) modules blacklisted by default...

However, that would not affect the first 8 GPIOs - 17,18, etc.


that is what I beleived to from reading the spec, so this is why I selected theses IO. but since you asked me to disable SPI, I thought that I missed something, and strangely, disabling the SPI changed the behaviour.
I enabled the SPI in raspian (feb version) to run another test, so this is why it was activated.

Just before I start doing the led investigation, I will do a vanilla install of latest raspian, just to make sure I did not mess something.
I am a strong Unix user/csh script writer(I work for a graphic chip cie (ASIC dept.)), but I know just enough about being a Linux root user to be dangerous... As such, maybe I did something stupid.

Can you confirm that if do a vanilla install, that all the IO settings (pull ups, etc) will be back to initial state.
I wonder if any info is stored in a permanent on board or on chip memory.

Your phone keypad is probably a simple 4x3 matrix. They're not that complicated - I had one on my BBC Micro connected to the user port onceuponatime...

-Gordon


yes it sounds like the std mapping for phone keyboard.
many thanks,


ben
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191
User avatar
Posts: 259
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)
by gordon@drogon.net » Sun Feb 17, 2013 5:44 pm
blachanc wrote:Just before I start doing the led investigation, I will do a vanilla install of latest raspian, just to make sure I did not mess something.
I am a strong Unix user/csh script writer(I work for a graphic chip cie (ASIC dept.)), but I know just enough about being a Linux root user to be dangerous... As such, maybe I did something stupid.

Can you confirm that if do a vanilla install, that all the IO settings (pull ups, etc) will be back to initial state.
I wonder if any info is stored in a permanent on board or on chip memory.



The pull-up/pull-down state is retained in on-chip non volatile memory, but the state of the other IO pins should default to input at boot time.

You can use the GPIO command to explicitly change the pull-up/down settings, however there's no way to read it from the SoC that I'm aware of.

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1537
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by blachanc » Sun Feb 17, 2013 7:53 pm
Hi Gordon,

good thing the drive/swim from your home to my place is so long, so not worth for you to come and kick my butt :oops:

LED6 had a life of its own, reboot would change the behavior..... as in "floating"

As my colleagues from the hardware board dev team once told me: show some respect to the hardware ;)
I am amazed to see that induction from jumper5 could induce enough in jumper 6...
I could swear I verified my harness was working fine with leds.c, but maybe I was too confident and was not carefull verifying the sequence.

BTW the issue is in the jumper itself, not in the jumper-header connection.
refer to the picture to understand what I mean...

Thanks a lot, I really re-learned something that I forgot for too long: recheck your connections...

Ok, now back to my keyboard decoding.
Attachments
continuity.jpg
continuity.jpg (58.5 KiB) Viewed 854 times
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191
User avatar
Posts: 259
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)