Hi all, I've recently started a project using the Intel Galileo. The goal is to operate AX-12A servo's using the Galileo board and make a four-legged robot.
Here's what I've already done.
I was able to use Arduino sketches to operate the servo's quite well. Here's a schematic of the setup I use. To communicate with the servo's I use digital pins 0 and 1, however the servo's use a half duplex dataline. This is why i use the 74LS241N component. Digital pin 2 on the galileo will determine the dataflow of this component.
To operate the servo's I use digitalWrite(2,1) to set the tri-state buffer to writing. After that I send my instructions to a servo using Serial1. Next the servo will respond with a status packet so the tri-state buffer has to read: digitalWrite(2,0). This works fluently.
The next step was to use an OS on the Galileo and try to operate the servo's from python code. So I was able to use get the Linux-image (Intel® Download Center) on an SD-card and got python running with the right modules. This is where I am a bit stuck. I can send instructions to the servo's using pySerial with the Galileo digital pins 0 and 1 and I can operate pin 2 for the tri-state buffer, however I never seem to get any more status packets from the servo's.
import serial import time AX_WRITE = 0x03 AX_READ = 0x02 RX_MODE = 0 TX_MODE = 1 s = serial.Serial() #Serial communication with servo's s.baudrate = 115200 s.port = "/dev/ttyS0" s.timeout = 0 s.open() File = open('/sys/class/gpio/gpio31/value', 'w') File.write('1') File.close() File = open('/sys/class/gpio/gpio32/direction', 'w') File.write('out') File.close() def writeFile(data): #This will set pin 2 to 0 or 1 File = open('/sys/class/gpio/gpio32/value', 'w') File.write(str(data)) #Communication goes like this #writeFile(TX_MODE) #send the instruction via serial #writeFile(RX_MODE) #read status via serial #Testing the speed of pin 2 while 1: writeFile(0) writeFile(1)
This is a bit of my code. The problem is that when I try to read the status packets from the servo, there's never anything to read. This all worked fine with the arduino sketch so I assumed it may be because switching pin 2 from write to read goes too slow. That's why I tried to test the speed of it. I measured the frequency with an oscilloscope and only got about 180Hz. The response from the servo's comes 0.5msec after the instruction was sent, so by the time pin 2 is ready for reading, the status packet from the servo is long gone.
I've been searching for a way to make pin 2 faster, however I haven't found anything yet. I know that in arduino sketches the speeds of those pins can be a lot faster than 180Hz, but I don't know how to do that in python. The only thing so far I have found was a mention of /dev/uio0 here (Sergey's Blog - Malinov Family Web Presence) under Fast I/O.
My question now is: Is there a way to get faster I/O speed, preferably on digital pin 2, with python and how? Or am I doing something wrong on my end?
I hope some of you can help me find an answer. If you need more details of what I did, feel free to ask.