skydive
Posts: 2
Joined: Fri Feb 14, 2014 1:08 pm

GPIO problems?

Fri Feb 14, 2014 1:46 pm

Hello!

We are a group of 4 who are currently working on a laser-communicator that will be connected to the GPIO. The communicator will work like this: A laser will be connected to the GPIO slot 7 and to GND. Now we will make it blink via a morse technique so that you can write simple text and send it by light basically. The problem we have right now is that the gpio is to slow for our demand, we can go for maximum 1000Hz or lower, otherwise the signal becomes to difficult to read. We believe that it is the Raspberry itself that can't handle higher frequencies, but at same time it should be able to go much faster. Suggestions?

Best regards

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: GPIO problems?

Fri Feb 14, 2014 5:47 pm

There is a report of some benchmarking here - http://codeandlife.com/2012/07/03/bench ... pio-speed/

That blog item is 18 months old and things may have changed since, but the code seems to be online so you could reproduce the tests. The results seem much more optomistic than what you are reporting: maybe your chosen output device is slow to light up and fade?
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

skydive
Posts: 2
Joined: Fri Feb 14, 2014 1:08 pm

Re: GPIO problems?

Fri Feb 14, 2014 7:33 pm

We didnt have any devices nor lasers in that test, it was simply made by connecting the osciloscope directly to the output 7 of the GPIO. Image So, if you look at the third and fourth picture we've tested the frequency 10000Hz directly from the Pi, it's hard to see it from the pictures, but it stutters and gitters alot back and fourth, giving us a really hard signal to translate. Picture 1 and 2 is from the reciever which is a photodiode, transmitted from the pi with a laser attached to GPIO 7 (which is tested and can maintain a frequency on 1Mhz). As the pictures are showing us, the signal is really irregular and hard to translate.

Suggestions on what the problem can be? (Using the Rpi.GPIO python)
Best regards

Kirk Fraser
Posts: 50
Joined: Thu Feb 13, 2014 6:52 am

Re: GPIO problems?

Fri Feb 14, 2014 7:56 pm

You might want to look at a Parallax Propeller microcontroller for your application. I think you'll find a more satisfactory O'scope response but as DeeJay wrote, getting that speed into a slow laser light-up and fade is another problem. I'm assuming you're going with a solid-state laser diode for speed instead of an externally pumped crystal, gas or liquid laser.

User avatar
joan
Posts: 14875
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO problems?

Fri Feb 14, 2014 8:21 pm

Code: Select all

#!/usr/bin/env python

import pigpio

GPIO=22

MICROS=200000

NONE=0

DASH=3
DOT=1
GAP=1
LETTER_GAP=3-GAP
WORD_GAP=7-LETTER_GAP

pigpio.start()

morse={
'a':'.-'   , 'b':'-...' , 'c':'-.-.' , 'd':'-..'  , 'e':'.'    ,
'f':'..-.' , 'g':'--.'  , 'h':'....' , 'i':'..'   , 'j':'.---' ,
'k':'-.-'  , 'l':'.-..' , 'm':'--'   , 'n':'-.'   , 'o':'---'  ,
'p':'.--.' , 'q':'--.-' , 'r':'.-.'  , 's':'...'  , 't':'-'    ,
'u':'..-'  , 'v':'...-' , 'w':'.--'  , 'x':'-..-' , 'y':'-.--' ,
'z':'--..' , '1':'.----', '2':'..---', '3':'...--', '4':'....-',
'5':'.....', '6':'-....', '7':'--...', '8':'---..', '9':'----.',
'0':'-----'}

def transmit_string(gpio, str):

   pigpio.wave_clear() # start a new waveform

   wf=[]

   for C in str:
      c=C.lower()
      print(c)
      if c in morse:
         k = morse[c]
         for x in k:

            if x == '.':
               wf.append(pigpio.pulse(1<<gpio, NONE, DOT * MICROS))
            else:
               wf.append(pigpio.pulse(1<<gpio, NONE, DASH * MICROS))

            wf.append(pigpio.pulse(NONE, 1<<gpio, GAP * MICROS))

         wf.append(pigpio.pulse(NONE, 1<<gpio, LETTER_GAP * MICROS))

      elif c == ' ':
         wf.append(pigpio.pulse(NONE, 1<<gpio, WORD_GAP * MICROS))

   pigpio.wave_add_generic(wf)

   pigpio.wave_tx_start()

pigpio.set_mode(GPIO, pigpio.OUTPUT)

transmit_string(GPIO, "HEllo world")

pigpio.stop()
International morse code. Unit set at 200,000 micros for testing. MICROS should be even, minimum value 2.

The code is not particularly clever, successive gaps should be combined into one pulse rather than 2 or 3.
morse.png
Unit of 4 milliseconds
morse.png (40.93 KiB) Viewed 1273 times

boyoh
Posts: 1462
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: GPIO problems?

Sat Feb 15, 2014 10:17 pm

skydive wrote:Hello!

We are a group of 4 who are currently working on a laser-communicator that will be connected to the GPIO. The communicator will work like this: A laser will be connected to the GPIO slot 7 and to GND. Now we will make it blink via a morse technique so that you can write simple text and send it by light basically. The problem we have right now is that the gpio is to slow for our demand, we can go for maximum 1000Hz or lower, otherwise the signal becomes to difficult to read. We believe that it is the Raspberry itself that can't handle higher frequencies, but at same time it should be able to go much faster. Suggestions?

Best regards
What is the Morse Technique you are using ?
BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

User avatar
DougieLawson
Posts: 38756
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: GPIO problems?

Sat Feb 15, 2014 10:31 pm

Why Morse? Even EBCDIC is better defined than Morse.

With any serial link you should use 8N1 ASCII. With a wired connection you can easily get the RPi running at 115,200 bps.

Your laser is just a faster serial link.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
Raspruss
Posts: 93
Joined: Thu Jan 23, 2014 3:50 pm
Location: Virginia, USA

Re: GPIO problems?

Sat Feb 15, 2014 11:10 pm

Without doing ANY thinking about the problem, none-the-less a related question: Wouldn't the Pi have significant "interference" problems with multitasking, thus the higher frequency tests having "glitches" and "jitter"?

hampi
Posts: 223
Joined: Fri May 31, 2013 11:29 am
Contact: Website

Re: GPIO problems?

Sat Feb 15, 2014 11:41 pm

DougieLawson wrote:Why Morse? Even EBCDIC is better defined than Morse.
That depends on the communication channel used. These channels can distort the signal quite a bit and there is usually some noise present too. The morse is one of the so called fuzzy modes which rely on human brain (kind of neural network) to interprete the message.

User avatar
joan
Posts: 14875
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO problems?

Sun Feb 16, 2014 8:41 am

Raspruss wrote:Without doing ANY thinking about the problem, none-the-less a related question: Wouldn't the Pi have significant "interference" problems with multitasking, thus the higher frequency tests having "glitches" and "jitter"?
That's why I suggested the use of pigpio. pigpio waveform, servo, and PWM functionality is unaffected by Linux scheduling jitter.

Return to “Beginners”