I have an SSC-32 connected to a Raspberry Pi through UART. A DC voltage between 0-5V is connected to the pin labeled “A” beside the baud jumpers on the SSC. I am using python with pyserial to read the voltage but I keep getting a white square as the returned value. I have tried all the analog inputs and they all return the same thing. I know the baud rate is set properly as I am able to successfully send commands to the SSC. I am also sure everything is grounded properly as the voltage being measured is the same one which is powering the controller.
The relevant code is:
ssc = serial.Serial('/dev/ttyAMA0', 115200, timeout=1.0)
ssc.write("VA \r")
battery = ssc.read()
print "%s" %battery
Thanks for any help!
EDIT:
I used the code from this post and successfully read the version, which is SSC32-V2.03XE. It is worth noting that when trying to read the analog pin, the SSC shuts down!
Hi,
Please provide us with one or more pictures clearly showing your SSC-32 and all connections to it. This will help identify any wiring or jumper issues that could be interfering.
Have you tried to do more than one analog read in a row? The manual states that the first analog read on any pin after boot up will not contain useful data as it is simply converting the pin to analog reading mode.
The SSC-32 turning off after an analog read is not a normal reaction to this command. What makes you think it is off?
Sincerely,
SSC32 RX, TX, GROUND
3.3V - 5V LEVEL SHIFTER(This is going to be difficult to follow, but as I mentioned, I can position the servos no problem, and have read the version multiple times. I have also tried the circuit without the level shifter and had worse performance.)
RASPBERRY PI UART
ANALOG INPUT ‘A’
POWER CONNECTIONS (power from the pcb is regulated 6V)
I did not get a clear picture of it, but the Pi and the SSC are grounded through the PCB.
I have measured the voltage at the analog in pin multiple times and it is always below 4.98V.
Yes, I have tried multiple reads. The above code is in a while loop (I should have included that).
I thought it was off because the UART LED stopped blinking, but I now realize this is normal behavior and just means no signals are being sent or received.
Please let me know if there is any other information you need.
Hi,
The reason you are getting a white square is because the value is returned in binary as one byte. Therefore, it must be read as such (and not as an ASCII character).
Please try to read the returned value as a binary value and see if you get better results.
Sincerely,
Thank you for your response.
The code that works is:
ssc.write("VA\r")
battery = ssc.read()
print(''.join(format(ord(x), 'b') for x in battery))