Shop OBEX P1 Docs P2 Docs Learn Events
Serial coms to the Pololu 8-Servo Controller — Parallax Forums

Serial coms to the Pololu 8-Servo Controller

uptonryanuptonryan Posts: 28
edited 2009-04-11 16:54 in General Discussion
Hi,

I am trying to build a system consiting of the Pololu 8 servo controller·available here·http://www.pololu.com/catalog/product/727· the manual is available here http://www.pololu.com/file/0J38/ssc04a_guide.pdf·

I am interfacing with the Pololu with a· Parallax SX Tech Tool Kit utilising the SX28AC/DP-G chip. the SX is running at 4MHz

·I have powered the SX28AC/DP-G with a 7.5 V and 1 amp transformer

The Pololu is seperately powered with 5V Lab power supply.

I have connected the RA3 pin of the SX28·to Logic in of the Pololu. I have connected a servo motor to position 0 of the pololu. I·have written a small program to send serial commands over RA3 pin to the Pololu in order to move the servo.

The program doesn't work(servo doesn't move) and all I get is a solid yellow light·on the Pololu.

I·connected·a red led and 470 ohm resistor acros the RA3 pin and the led lights up indicating data is being sent. I brought the logic level input of the pololu low and the yellow light flickered and green led on Pololu lit up indicating the Pololu chip is working.

I suspect my assembler code is faulty. The code is attached bellow. Can you help?

;==============================================================================
; Sero motor controller
;==============================================================================
include "Setup28.inc"
Reset Main
;**********************Program Variables***************************************
;
; Port assignments : Bit variables
;
rx_pin·········· EQU·· ra.2···· ;UART transmit input
tx_pin·········· EQU·· ra.3···· ;UART transmit output
;**********************Register definitions (bank 0)

··········· org···· 8······ ;First register address in main memory bank
temp······· ds····· 1······ ;Temporary storage
byte······· ds····· 1······ ;Temporary UART shift register
flags······ DS····· 1······ ;Program flags register
number_low· ds····· 1······ ;Low receive byte
number_high ds····· 1······ ;High receive byte
hex········ ds····· 1······ ;Value of received hex number
string····· ds····· 1······ ;Indirect pointer for text output
rx_flag···· EQU···· flags.5 ;Signals reception of one byte
··········· org···· 10h···· ;Variables in bank 3
serial····· =······ $······ ;UART bank
tx_high···· ds····· 1······ ;Low transmit byte
tx_low····· ds····· 1······ ;High transmit byte
tx_count··· ds····· 1······ ;Number of remaining bits to be sent
tx_divide·· ds····· 1······ ;Counter for transmit timer (/16)
rx_count··· ds····· 1······ ;Number of bits recieved
rx_divide·· ds····· 1······ ;Counter for receive timer
rx_byte···· ds····· 1······ ;Buffer for received bytes
; Values for various baud rates:

; ***9600
baud_bit···· = 1
start_delay· = 2+1+1·
int_period·· = 217

;************** ISR CODE*******************************************************
interrupt····· ORG $000
bank serial·· ; Select the "Serial bank· ;1
:transmit
· clrb······ tx_divide.baud_bit····· ;Clear transmit timer flag
· inc······· tx_divide············· ;Increment the counter
· stz······························ ;Set Z flag for next instruction··
· snb······· tx_divide.baud_bit···· ;Execute the transmit routine on (2 ^ baud_bit)-th interrupt.
· test······ tx_count·············· ;Are we sending data?
· jz········ :receive·············· ; no continue with receiver
· clc······························ ; yes, prepare stop bit, and
· rr········ tx_high··············· ; shift to next bit
· rr········ tx_low
· dec······· tx_count·············· ;Decrement bit counter
· movb······ tx_pin, / tx_low.6···· ;Output next bit
:receive
· movb······ c, rx_pin············· ;Store received bit in carry flag····
· test······ rx_count·············· ;Are we receiving?
· jnz······· :rxbit················ ; yes, continue receiving
· mov······· w, #9················· ; no, prepare 9 bits
· sc······························· ; if no start bit, continue
··· mov····· rx_count, w··········· ; if start bit, set bit counter
· mov······· rx_divide, #start_delay; Set 1.5 bit per periods
:rxbit
· djnz······ rx_divide, :rxdone···· ;In the middle of the next bit?
· setb······ rx_divide.baud_bit···· ; yes, set 1 bit period
· dec······· rx_count·············· ; Last bit?
· sz······························· ; no,
·· rr······· rx_byte··············· ; save bit
· snz······························ ; yes,
·· setb····· rx_flag··············· ;· set flag
:rxdone
· mov······· w, #-int_period······· ;Interrupt every int_period
··································· ;clock cycles
··································· ; (163 for 19,200 Bd)
:end_int
· retiw
;************** Program Data*******************************************************
_moveservo1··· dw··· $80,$00,$04,$01,$02,$58
_moveservo2··· dw··· $80,$00,$04,$01,$0F,$A0
;************** Sub Routines*******************************************************
; Read byte from the UART
;
get_byte
·· jnb·· rx_flag, $············ ;Wait until a byte has been recieved
·· clrb· rx_flag··············· ;Reset rx_flag
·· mov·· byte, rx_byte········· ;Save byte
; Send a byte via the UART
send_byte
···· bank··· serial
:wait
···· test··· tx_count·········· ;Wait for a pause
···· jnz···· :wait··
···· ;not···· w················· ;negative logic
···· mov···· tx_high, w········ ;save data byte
···· setb··· tx_low.7·········· ;Set start bit
···· mov···· tx_count, #10····· ;1 start + 8 data + 1 stop bit
···· retp······················ ;Return with page adjust
send_string
···· mov··· string, w··········· ;save address
:loop
···· mov··· w, string
···· mov··· m, #0
···· iread
···· mov··· m, #$0f
···· test·· w
···· snz
···· retp
···· call·· send_byte
···· inc··· string
···· jmp··· :loop

;************** Main Program code*******************************************************

ORG 100h
;
; Program execution after power-on or reset starts here
;
Main

···· mov ra,· #%1011······· ;Initialize port RA
···· mov !ra, #%0100······· ;Set RA's inputs and outputs
; clear memory
include "Clr2x.inc"
···· mov····· !option,#%10011111···· ;Enable RTCC interupts
;Main program
:Loopall
···· mov w, #_moveservo1
···· page send_string
···· call send_string
:Loop
· decsz $08··· ; 1/2
··· jmp :Loop·· ; 3
···· mov w, #_moveservo2
···· page send_string
···· call send_string
· jmp· :Loopall··· ; 3
END·· ;End of program code

Post Edited (uptonryan) : 3/22/2009 2:35:34 AM GMT

Comments

  • uptonryanuptonryan Posts: 28
    edited 2009-03-21 11:47
    After much fiddling I decided to change over to BASIC. Which is a lot easier to program in.

    I added the Mini SSC II Mode jumper

    I changed the baud to T9600

    I powered the servo from its own lab power supply.

    I powered the Pololu off the SX Tech Vdd and Vss

    and it works.!

    But it seams to only work for about 2min and then crashes with the pololu going dead, No led nothing. ANy ideas on why this is so?





    '
    ' Program Description
    '
    '
    ' This program talks to pololu 8 servo controller via pin 3 of the SX28 chip

    '
    ' Device Settings
    '

    DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX
    FREQ 4_000_000
    ID "Servo"

    '
    ' IO Pins
    '

    SOut PIN RA.3 OUTPUT ' output to pololu

    '
    ' Constants
    '

    Baud CON "T9600"



    '
    ' Variables
    '



    ' =========================================================================
    PROGRAM Start
    ' =========================================================================

    '
    ' Subroutine Declarations
    '

    TX_BYTE SUB 1, 2 ' transmit byte


    '
    ' Program Code
    '

    Start:


    Main:


    serout SOut, Baud,$FF 'set pos servo 0
    serout SOut, Baud,$00 'set pos servo 0
    serout SOut, Baud,$55 'set pos servo 0

    PAUSE 50

    serout SOut, Baud,$FF 'set pos servo 0
    serout SOut, Baud,$00 'set pos servo 0
    serout SOut, Baud,$F5 'set pos servo 0
    PAUSE 50


    GOTO Main

    Post Edited (uptonryan) : 3/22/2009 2:27:10 AM GMT
  • uptonryanuptonryan Posts: 28
    edited 2009-03-22 02:30
    I managed to get the Pololu Mode working at 57600 baud.

    The servo now moves back and forth, but only 180 degrees. Does anyone know how to make it move 360 degrees?

    Every now and then it seams to loose position and the servo clicks like it is being forced beyond its limits. I'm not too sure how to fix this. It's as if the servo positional information is wrong or slipping somehow.

    I have connected ground wire of the Pololu to ground of the SX tech board and that seam to stop the pololu crashing.

    '
    ' Program Description
    '
    '
    ' This program talks to pololu 8 servo controller via pin 3 of the SX28 chip

    '
    ' Device Settings
    '

    DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX
    FREQ 4_000_000
    ID "Servo"

    '
    ' IO Pins
    '

    SOut PIN RA.3 OUTPUT ' output to pololu

    '
    ' Constants
    '

    Baud CON "T57600"

    '
    ' Variables
    '

    idx VAR Byte ' loop counter
    owByte VAR Byte ' byte for OW work
    owSerial VAR Byte(8) ' OW serial number
    tmpB1 VAR Byte ' subroutine work vars
    tmpB2 VAR Byte
    tmpB3 VAR Byte
    tmpW1 VAR Word

    ' =========================================================================
    PROGRAM Start
    ' =========================================================================

    '
    ' Subroutine Declarations
    '


    '
    ' Program Code
    '

    Start:
    'set speed to fast
    serout SOut, Baud,$80 'synchronization value
    serout SOut, Baud,$01 'pololu device
    serout SOut, Baud,$01 'cmd
    serout SOut, Baud,$00 'servo
    serout SOut, Baud,$00 'set pos servo 0

    PAUSE 2000

    'set neutral
    'serout SOut, Baud,$80 'synchronization value
    'serout SOut, Baud,$01 'pololu device
    'serout SOut, Baud,$05 'cmd
    'serout SOut, Baud,$00 'servo
    'serout SOut, Baud,$1E 'data1 neutral 3000
    'serout SOut, Baud,$00 'data2 neutral
    'PAUSE 2000

    'set range and direction
    serout SOut, Baud,$80 'synchronization value
    serout SOut, Baud,$01 'pololu device
    serout SOut, Baud,$00 'cmd
    serout SOut, Baud,$00 'servo
    serout SOut, Baud,%01011110 'set range 30

    PAUSE 2000

    serout SOut, Baud,$80 'synchronization value
    serout SOut, Baud,$01 'pololu device
    serout SOut, Baud,$04 'cmd
    serout SOut, Baud,$00 'servo
    serout SOut, Baud,$00 'data1
    serout SOut, Baud,$00 'data2

    PAUSE 2000

    Main:

    'reset
    'serout SOut, Baud,$80 'set pos servo 0
    'serout SOut, Baud,$02 'set pos servo 0
    'serout SOut, Baud,$00 'set pos servo 0

    serout SOut, Baud,$80 'synchronization value
    serout SOut, Baud,$01 'pololu device
    serout SOut, Baud,$03 'cmd
    serout SOut, Baud,$00 'servo
    serout SOut, Baud,$00 'data1
    serout SOut, Baud,$01 'data2

    'serout SOut, Baud,$FF 'set pos servo 0
    'serout SOut, Baud,$00 'set pos servo 0
    'serout SOut, Baud,$FE 'set pos servo 0

    PAUSE 2000

    serout SOut, Baud,$80 'synchronization value
    serout SOut, Baud,$01 'pololu device
    serout SOut, Baud,$03 'cmd
    serout SOut, Baud,$00 'servo
    serout SOut, Baud,$7F 'data1
    serout SOut, Baud,$70 'data2


    'serout SOut, Baud,$80 'synchronization value
    'serout SOut, Baud,$01 'pololu device
    'serout SOut, Baud,$04 'cmd
    'serout SOut, Baud,$00 'servo
    'serout SOut, Baud,$7F 'data1
    'serout SOut, Baud,$7F 'data2


    'serout SOut, Baud,$FF 'set pos servo 0
    'serout SOut, Baud,$00 'set pos servo 0
    'serout SOut, Baud,$02 'set pos servo 0
    PAUSE 2000


    GOTO Main

    Post Edited (uptonryan) : 3/22/2009 2:38:55 AM GMT
  • uptonryanuptonryan Posts: 28
    edited 2009-03-22 13:50
    I just read Jon Williams book Practical SX/B

    http://www.parallax.com/tabid/460/Default.aspx

    And it was awsome. I applied the lessons learned to tidy up the code. I think I should read back from the Pololu into the SX 28 to check coms as the Pololu is still crashing.

    '==========================================================================
    '
    ' File: servoworking.sxb
    ' Purpose : To control the Pololu 8 servo control and corresponding servos
    ' Author : Ryan Upton
    ' Company : Upton Robotics pty ltd
    ' E-mail : adslpuay@tpg.com.au
    ' Started : 22 / 03 / 09
    ' Updated : 22 / 03 / 09
    '
    '
    ' Program Description
    '
    '
    ' This program talks to pololu 8 servo controller via pin 3 of the SX28 chip

    '
    ' Device Settings
    '

    DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX
    FREQ 4_000_000
    ID "Servo"

    '
    ' IO Pins
    '

    SOut PIN RA.3 OUTPUT ' output to pololu

    '
    ' Constants
    '

    Baud CON "T57600"
    Sync CON $80 'Pololu Synchronisation value
    PDEv CON $01 'Pololu Device

    Cmd0 CON $00 'Pololu Command 0 Set Range and direction
    Cmd1 CON $01 'Pololu Command 1 Set Speed
    Cmd2 CON $02 'Pololu Command 2 Set Position 1 data byte
    Cmd3 CON $03 'Pololu Command 3 Set Position 2 data byte
    Cmd4 CON $04 'Pololu Command 4 Set Position Absolute
    Cmd5 CON $05 'Pololu Command 5 Set Neutral

    Ser0 CON $00 'Servo 0
    Ser1 CON $01 'Servo 1
    Ser2 CON $02 'Servo 2
    Ser3 CON $03 'Servo 3
    Ser4 CON $04 'Servo 4
    Ser5 CON $05 'Servo 5
    Ser6 CON $06 'Servo 6
    Ser7 CON $07 'Servo 7

    '
    ' Variables
    '

    idx VAR Byte ' loop counter
    tmpB1 VAR Byte ' temporay byte 1
    tmpB2 VAR Byte ' temporay byte 2
    tmpTX VAR Byte ' transmit byte
    tmpW1 VAR Word

    ' =========================================================================
    PROGRAM Start
    ' =========================================================================
    '
    ' Subroutine Declarations
    '

    SET_SERVO_SPEED_TO_FAST SUB 0
    RESET_POLOLU SUB 0
    SET_SERVO_RANGE_DIRECTION SUB 0
    MOVE_SERVO SUB 2
    DELAY_MS SUB 1, 2 ' delay in milliseconds
    TX_BYTE SUB 1 ' transmit a byte

    '
    ' Program Code
    '

    Start:

    'Reset
    'RESET_POLOLU

    'set servo speed to fast
    SET_SERVO_SPEED_TO_FAST

    'set range and direction
    SET_SERVO_RANGE_DIRECTION

    DO

    FOR idx = 0 To 1
    READ Move_Servo_Byte1 + idx , tmpB1
    READ Move_Servo_Byte2 + idx , tmpB2

    MOVE_SERVO tmpB1, tmpB2

    NEXT

    LOOP


    '
    ' Subroutines
    '

    'reset
    SUB RESET_POLOLU
    TX_BYTE Sync 'set pos servo 0
    TX_BYTE Cmd2 'set pos servo 0
    TX_BYTE $00 'set pos servo 0

    ENDSUB

    'set servo speed to fast
    SUB SET_SERVO_SPEED_TO_FAST

    TX_BYTE Sync 'synchronization value
    TX_BYTE PDEv 'pololu device
    TX_BYTE Cmd1 'cmd to set speed
    TX_BYTE Ser0 'servo 0
    TX_BYTE $00 'set pos servo 0
    DELAY_MS 2000

    ENDSUB

    'set range and direction
    SUB SET_SERVO_RANGE_DIRECTION
    TX_BYTE Sync 'synchronization value
    TX_BYTE PDEv 'pololu device
    TX_BYTE Cmd0 'cmd 0 set range and direction
    TX_BYTE Ser0 'servo 0
    TX_BYTE %01011110 'set range 30
    DELAY_MS 2000

    ENDSUB

    'move servo
    SUB MOVE_SERVO
    TX_BYTE Sync 'synchronization value
    TX_BYTE PDEv 'pololu device
    TX_BYTE Cmd3 'cmd 3 set Position 2 Data bytes
    TX_BYTE Ser0 'servo 0
    TX_BYTE tmpB1 'data1
    TX_BYTE tmpB2 'data2

    DELAY_MS 2000

    ENDSUB

    'Delay
    SUB DELAY_MS
    IF __PARAMCNT = 1 THEN
    tmpW1 = __PARAM1 ' save byte value
    ELSE
    tmpW1 = __WPARAM12 ' save word value
    ENDIF
    PAUSE tmpW1
    ENDSUB

    ' Transmit a byte
    SUB TX_BYTE
    tmpTX = __PARAM1
    SEROUT SOut, Baud, tmpTX
    ENDSUB




    'pg101
    'set neutral
    'serout SOut, Baud,Sync 'synchronization value
    'serout SOut, Baud,PDEv 'pololu device
    'serout SOut, Baud,Cmd5 'cmd
    'serout SOut, Baud,Ser0 'servo
    'serout SOut, Baud,$1E 'data1 neutral 3000
    'serout SOut, Baud,$00 'data2 neutral
    'PAUSE 2000

    'set absolute position
    'serout SOut, Baud,Sync 'synchronization value
    'serout SOut, Baud,PDEv 'pololu device
    'serout SOut, Baud,Cmd4 'cmd 4 set postion absolute
    'serout SOut, Baud,Ser0 'servo 0
    'serout SOut, Baud,$00 'data1
    'serout SOut, Baud,$00 'data2

    'PAUSE 2000

    'mini SSC II Mode
    'serout SOut, Baud,$FF 'set pos servo 0
    'serout SOut, Baud,$00 'set pos servo 0
    'serout SOut, Baud,$FE 'set pos servo 0



    '
    ' User Data
    '

    Move_Servo_Byte1:
    DATA $00 '0
    DATA $7F '2

    Move_Servo_Byte2:
    DATA $01 '1
    DATA $70 '3

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • uptonryanuptonryan Posts: 28
    edited 2009-03-28 12:28
    Hi,

    In my last post I talked about the pololu device crashing. Well I brought another power supply. So I was able to set up·with three·independent power supplies: one for the pololu, one for the sx28 and one for the servo motor. With this setup the pololu no longer crashes.

    Previously·the 5V pololu was connected (via the pololu jumper) to the server motor power supply. I suspect that the reason for crashing was that the pololu chip uses a voltage regulater to drive the voltage to 5V and the servo's I use wouldn't be driven at 5V or the noise on the servo power line was crashing the pololu chip.

    So now I have to figure out a way to isolate all three·power·sources from each other while only using one power supply. Do you think if I add a big enough capacter that this will filter out the noise and I can use one power supply for all three?

    Any suggestions?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-28 15:58
    Ryan--

    This is a fascinating thread! You persevere with no input from anyone! I wish I could help a bit.

    Here is what I've done when facing what I THINK you may have determined to be your problem. Use a single battery to power everything via appropriate regulators that you build. For example, my machine uses two 12 volt, 12 amp hour batteries connected in parallel for a total of 12 volts and 24 amp hours.

    Twelve volts powers the gear motors. I built a 5 volt DC-DC regulator to power the Stamp(s). I am building an 8 volt DC-DC regulator to power the web cam. The "secret" to all of this is that all grounds are common. These little regulators are dirt simple to build, even for a newbie like me. They might cost five bucks, each. Maybe less.

    Here is a picture of one that provides a regulated +5vdc at up to·1 amp·to power my SX48 Module and eb501 Bluetooth device . . .

    03-03-09%20DC-DC.jpg

    Here is another one, a bit more sophisticated that provides +5vdc at up to 5 amps. (Or, when I replace the 9 volt battery with the two 12 volt, lead-acid batteries, it WILL provide up to 5 amps! [noparse]:)[/noparse]

    I hope this addresses part of your issue.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • uptonryanuptonryan Posts: 28
    edited 2009-03-28 17:47
    Awsome,

    So what your saying is that if I use regulators that should go some way to cleaning up the supply and stop the crashing!

    I do persevere, some people call it being stubborn but I feel experience has taught me thats often the only way to solve technical problems. Thomas Edison had over 1000 goes at the lightglobe before he got it. Sometimes it does get lonely hearing the sound of my own voice in this thread, but hearing from a fellow techie like you makes it all worth while!

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-28 19:20
    Ryan--

    I wish someone that REALLY knows their electronics would jump in and reply. What I can say is that all the grounds of the different supplies should be connected. Now, doing this with wall transformers may be perfectly fine. I DO NOT KNOW. However, it always bothered me when I did it. The way to get around that (perhaps) psychological barrier is to run everything off either a single or multiple batteries. There is nothing wrong with connecting the grounds of different batteries, even if they are of differing voltage and amperage ratings.

    Even better, in my opinion (worth little in the world of electronics; make that "nothing"), is to use a single battery or battery "pack" (I consider my two 12 volt, 12 amp hour, lead-acid batteries connected in parallel to be a single battery for these purposes) and build DC-DC regulators that provide the proper voltage. Please note that in my picture, I am using the wrong color wires for VIN (positive voltage in) and VSS (ground). Positive should ALWAYS be red and ground should ALWAYS be black. Even though I labeled them·specifically because they were the wrong colors, that is not good enough. (I thank the person that pointed out my mistake.)

    If you are interested in these little circuits, they can easily be built on breadboards. The regulator Parallax uses on their Professional Development Board is an·LM1084 and they use an LM2940 on their Board of Education. The regulators are inexpensive. I buy mine from Digi-Key. (If you hit that link and merely enter one of the part numbers you will eventually wade through their selection routines--which are actually necessary and do help--to find exactly what you want. The datasheets (complete technical descriptions of the part) are also available. The datasheets include useful diagrams. However, I use the Parallax diagrams, which are either identical or (in my opinion), better. (Professional Development Board schematic; DC-DC power regulation circuitry on page 7. Board of Education schematic; the DC-DC power regulation circuitry is marked as LM2940.)

    The new Professional Development Board (Rev. D) schematic shows the use of 47uF capacitors. Unfortunately, Parallax does not specify what kind. Are they aluminum electrolytic or solid tantalum? There is a difference, with tantalum being the preference in situations involving large temperature ranges. Tantalum capacitors are also much more efficient, therefore smaller. And, I BELIEVE that a tantalum capacitor of 1uF is equivalent to an aluminum electrolytic capacitor of 25uF. Tantalum capacitors are also more expensive. I HOPE someone more knowledgable than me will jump in here with corrections, as necessary. In any event, I have successfully used 10uF and 22uF aluminum capacitors--as seen in my pictures, above--but, have some solid 10uF and 22uF capacitors coming from Digi-Key. (The actual values seem to make little difference as long as they are 10uF or above. In reading the datasheets, I am discovering why, I THINK. [noparse]:)[/noparse]

    I hope some of this helps.

    [noparse][[/noparse]Edits for grammar.]

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.

    Post Edited (Bill Chennault) : 3/28/2009 8:00:06 PM GMT
  • uptonryanuptonryan Posts: 28
    edited 2009-03-29 04:07
    Bill,

    When faced with a problem its best to start with the question.

    Question : Can three devices, servo,pololu & SX28 be fed off the same power.

    All Common grounds should and can be connected. If they are not then that may cause voltage differences in the communication wires between the circuits.

    What noise causes the problem? Well when the servo motor starts up it draws a rush of starting current. This rush of current can cause less current to be availabble for the other devices and may cause a voltage dip that resets the pololu chip.

    Also all three devices may require different voltages. For example the pololu requires 5V but the Servo motors require 6V. A Voltage divider circuit made out of resitors should be able to fix this problem.

    So primarily I see this as a noise and filtering problem. A Voltage regulator will help to lock voltage at a certain value but I am not sure if it will filter out the noisy servo motors. Page 427 of "Programming the SX Microcontroller by Gunther Daubach talks about this exact problem and he places a 3300 uF electrolytic capacitor across ground and source to filter for noise.

    A capactor is a·reservoir of charge, sort of like a battary and so when the servo motor starts and draws a large current the capacitor supplies this extra current without the voltage dropping. These capacitors are called reservoir capacitors.

    http://www.hobbyprojects.com/the_diode/reservoir_capacitor.html

    At low frequencies the capacitor is usually an electrolytic type, but at higher frequencies, where smaller values are required, other types can be used.·
    But the real question is what size should it be?

    "The art of electronics"· Horowitz & Hill page 45 talk about Power supply filtering and full wave rectification.

    They suggest that the
    ··········· R-load x·C >> 1/f

    In order to ensure small ripple, by making the time constant for·discharge much longer than the time between recharging.

    The equation is i(t)=C dv(t) / dt. This means the change of voltage divided by the change in time multiplied by the capacitance equals the startup current.

    If we connect all three devices in parralled then the currents add i-pololu + i-sx + i-servo = i-total but the Voltage supplied is the same for all three.

    If we place a capacitor in series with the three parralled devices then the total voltages of capacitor and devices-Total·add but the current of the capacitor and·devices(combined)·are the same.

    If dV=Iload/fC· which means the change in voltage equals the startup current load divided by the frequency of that load and capacitance.

    So this means the size of the capctior depends on the amount of startup current the servo motor draws and frequency at which it draws it. If we assume a maximum frequency of 60KHz (maxium clock speed of the SX28·)·The current change when one servo motor turns on (about·1 amp) so that means for 5V C=1/5*60000 =>·83 uF Capacitor. If we add a bit extra for a margin of error then·then 100uf shouldbe fine.

    But all this is just a guess, like you I'd like to know the real answer.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton

    Post Edited (uptonryan) : 3/29/2009 5:02:52 AM GMT
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-29 14:58
    Ryan--

    Here is another problem--that sorta sounds like yours--I solved by paying attention to the experts on this forum on many different threads. The scenario went like this . . .

    I have a robot which I built. It's logic consisted of five Stamps, a master and four slaves all in a tightly coupled, pin-to-pin network. I used Parallax's HB-25 motor controllers to control my two gear motors.

    This strange scenario was logic-hardware heavy and software lite. It worked perfectly. Soon, it was time for me to move on. So, I acquired one of RobotWorkshop's drop-in SX48 modules, which are pin for pin compatible with the BS2p40. Not only did I get an interrupt structure, but the speed increase was stunning. As I was writing various pieces of test code, I soon discovered that I could not turn on the HB-25's. Well, the SX48 is much faster, so I figured the pulse widths sent to the HB-25s had to be different. This was correct and the one with which I was testing finally started doing something.

    But, it was strangely erratic and I could not get the other one to work at all. I even tried different HB-25s. (I like'em!) No joy. Then, I remembered that long wires act like antennas. This may have dramatic affect on sensitive electronics. The electronics behind the pins of the microcontroller and the HB-25s are sensitive. I chose something that looked like the midpoint of the left HB-25's control wire and tied it to VSS (ground) via a 0.1uF ceramic capacitor. The HB-25 worked perfectly. Here is a very good, short·essay on the subject.

    I performed the same thing with the right HB-25 and received the same instant gratification. So, just for the heck of it, I stuck one in the very long line I use to control a big solid state relay. (I wasn't having any problems with it, but I was on a roll.) I also put one in my Bluetooth·RX wire. I have read where folks sometimes use two capacitors, one near each end of the long wire.

    Got any long wires from microcontroller pins to the Pololu controller?

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • uptonryanuptonryan Posts: 28
    edited 2009-03-29 15:35
    Bill,

    Yes this is great advise. Your talking about transmision lines. I haven't seen these problems yet but I havn't looked for them yet [noparse];)[/noparse] There is all shorts of maths to do with transmission lines. When you have a transmision line a delay is created just like in telephone lines, that causes synchronisation problem. The maths is fairly complex.

    Page 602 of the Art of electronics by horowitz & hill read.."transmission line effects due to the length and inductance of the signal lines themselves" ..."rise times less than 1ns"...."these effects so severe that signals runs of more than 1 inch must be treated as transmission lines and properly terminated".

    One way to solve this is by using a motherboard with ground plane. Slots in the motherboard allow cards to be inserted and therefore correct termination of bus transmission lines.

    Putting capactiors across intput lines compounds the problem by creating large ground currents during logic transmission.

    A better way is to use transmision line terminators using resistor pullups or pulldowns. A popular way (CMOS or TTL) is to use a AC termination consisting of a series resistor and capacitor connected to ground. The resistor should be close to the characteristic impedence of the bus (100 ohms ) the capactior should be roughly 100pF

    You should probably terminate only on one end of the transmission line in case there are differences between the ground voltages at each transmission line end that would create ground current over the transmission line. Could be wrong on this, depends on your setup. You want all grounds at the same voltage potential.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-29 19:57
    Ryan--

    Well, I definitely put a bypass cap on the SX line that receives data from my Bluetooth device. I wonder: Is that a transmission line (from the Bluetooth device) or an input line to the SX48?

    Maybe I should buy Horowitz and Hill's book.

    Wonder why this subject is not receiving any input from those that really know? Do you think all input to this thread uses bypass caps? I am truly disappointed because there are so many here that·know so much.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-29 20:18
    Ryan--

    I just bought "The Art of Electronics." Thank you very much for the recommendation. Sorry I could not help you as much.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • khd00khd00 Posts: 13
    edited 2009-03-30 02:34
    Except for Ryan's tilt toward the "I'm talking to myself" episode which worried me a little....HA... I have enjoyed the discussion.

    I'm sort of in Bill's position but not as far along. I wanted to have a little more speed and a little more complexity.

    Good discussion guys.

    Kevin
  • uptonryanuptonryan Posts: 28
    edited 2009-03-30 02:57
    Bill, Kevin

    It is great to talk to people about this. I don't mind if people don't know or if they say something wrong. I am not perfect myself, mistakes are how we learn. Even wrong information tells me what not to do. Bill you help has been right so far and it's great to talk with you.

    I own my own business Upton Robotics Pty Ltd. http://www.uptonrobotics.com I started this business to do one thing, build robots. I love robots. I have some ideas about the locus of conciousness and Artifical Intelligence that I want to commercialise. I read a lot and widely from Alan Turing to Bill Gates to get inspiration and now want to put some ideas into practice.

    I think the data from the Bluetooth device could be a transmission line and so I would terminate one end with a RC terminator. Also if the lines are long it may also be good to twist the lines together in order to stop them acting like antennas.

    The "Art of Electronics"is a good encyclopedia of electronics for commonsense practical questions. The stuff you only really learn from practical experience.It is not a theory book. The only problem is that at times it can be flakey and wrong with no explanation. But it's the book I pickup first. Thats ok you'll help me next time.

    At the moment I am working on a rather simple application but my next idea is to build a dancing robot. I like the dancing robot because it can be simple to very complex and should be a good way to test out some of my theories.

    Have you guys heard much about the CM-1K 1024 Neuron Chip from CogniMem ?

    http://roadnarrowsrobotics.com/products/CogniMem/CM-1K/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-30 21:35
    Ryan--

    What an exciting chip! I bet they will have to do a little work on their web site before they sell a BUNCH of them, though. [noparse]:)[/noparse]

    What I am waiting for is a chip like that wherein EACH neuron is connected to every other neuron. 1024^1024 patterns each consisting of 1024 neurons! I suppose it would look like a cube and cooling would be a massive problem.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • uptonryanuptonryan Posts: 28
    edited 2009-03-30 23:57
    But its expensive, 100 dollars US.

    Plus I'm not sure what type of neural net they use. It might be fast having a device level neural net but creating a software based neural net would be cheaper and more flexible.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • khd00khd00 Posts: 13
    edited 2009-03-31 02:40
    I quickly glanced at the chip but didn't get into to it but looks interesting. I played around w/ neural nets back in my VB days and implementing all but the simplest would take a lot of processing and a lot of code space to do much more than just simple reactions. Think what it would take to run to the light or run from heat and program it to learn that light is good and heat is bad without telling it in advance.

    $100 USD, isn't that like a 50% discount for the Pound? (SP)

    Kevin
  • uptonryanuptonryan Posts: 28
    edited 2009-03-31 05:29
    Kevin

    I think you are right to say that robotics problems take a lot of processing and code space. Just because something is hard to do·is not a reason to not do it, actually when the going gets tough·that usually means you are on the right track.

    I·beleive current nerual network models are wrong. I do not think··they truely reflect the activities of a neuron, or that swarm technolgies·truely reflect the behaviour of a number of neurons.

    I'm trying to build a prototype, that might mean that the first few are not fully battery operated and other such compramises are made. As I see it the interesting stuff is the smarts of the software and that is what my focus is.

    The question is do I have a pc (core2 duo etc)·and hook that up to a number of sx28, pololu chips, servos·etc·or can I stop at the microcontroller level ?

    Is it better to have one big computer or a number of small microcontrollers? or a mixture of both?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-31 14:05
    Ryan--

    A microcontroller is just that: A microcontroller. It is not a PC with multiple gigs of RAM and running at 3GHz, or some big number like that. Nor does it have high speed access to a terrabyte of storage.

    But, you knew all that. Microcontrollers are often used by folks to build robot-things. But, by far the VAST use of microcontrollers is in the commercial world. Putting a dedicated microcontroller in a product is probably the cheapest way in the world to add features and functionality that pay for themselves almost instantly via advanced utility. Microcontrollers are in almost everything. One day, they will be.

    I have had as many as five Stamps communicating among each other to run one of my robots. It was highly successful for my learning goals. Still, it sure would have been nice to have had a wireless, high speed link to a PC talking to my terrabyte disk server! And, that is exactly what I am working on now. I have a single SX48 driving a skid steer via a VB6.0 GUI over Bluetooth. A web cam will be mounted on it very soon. (Maybe this week if Digi-Key shows up by way of UPS Ground with regulators!)

    But, I have already discovered the limitations of Bluetooth. For starters, it absolutely hates a 9,000 pound rock in my back yard and the slightly smaller ones used as seats lining my rear patio. This turns into a bad situation when Bluetooth loses comm with the PC controlling the robot, if the robot is headed towards the back of my property which ends--rather abruptly--in a 50 foot cliff, it just merrily chews up grass on its way to doom unless I rush out the back door and save it. (Rushing is difficult for me.)

    So, Bluetooth has got to go. I'm looking at both Parallax's 433Mhz transmitter/receiver pairs and at WiFi to serial solutions. My goal is to allow the microcontroller to do what it was designed to do; simple, repetitive tasks using very few on-board computing resources. However, I want to augment that microcontroller with a very healthy PC--perhaps, more than one--wirelessly.

    Microcontrollers can be made to do some amazing things, but they will never be I, Robot.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • uptonryanuptonryan Posts: 28
    edited 2009-03-31 14:55
    This is an awsome thread.

    I have often thought about having a wireless connected PC but control equations are finely tuned and when you introduce delays and interference via wireless it makes life harder. To this end I am going to try and locate it all together. Wireless does have some benefits for telerobotics, which is awesome.

    Additionally there are some benefits to having lots of smaller microcontrollers in that you are creating a parrallel architecture. Using one PC means that the robot is at risk from the Halting problem (as discussed by Alan Turing). The Halting problem arises when you have one processor using the Von Neumann Architecture. There are some problems the Von Neumann Architecture can't handle, for example problems with no solutions like a neverending for loop, that can cause the single processor to lock. A parrallel machine can get around this because if one processor(or microcontroller) locks then the others can detect it and unlock it.

    But parrallel machines don't solve all problems as sometimes you want one processor working uninteruppted on a problem and the constant swaping and juggling of a parrallell network interferes with this efficency.

    From what little I know of the human brain, problems are divided and isolated from each other. You as an individual are not aware of the chemistry in your stomach or the process of breathing. The human body effectily hides those processes from you concious brain. I beleive that this is a technique of algoritm matching. It might be good to use SX28 chips to manage certain problems on the robot and other problems handled by the PC.

    What do you think?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-31 15:17
    Ryan--
    It might be good to use SX28 chips to manage certain problems on the robot and other problems handled by the PC.
    Exactly. That is precisely what I am doing. An EXTREMELY simple example will occur when I re-implement the gear motor optical encoders on my robot. They will own pins on the SX48. When I am not actively tele-operating the machine, it should continue its last command (that might be "stop"). To do this with some accuracy, the SX48 will simply compare encoder counts and cause the gear motors to re-equalize, when necessary. (I've done all this before using multiple Stamps.)

    But, what about the case--again, simple--wherein I want the robot to follow a particular path it has "learned" before? (Data points and commands for this path are stored on the PC or disk storage server.) In that event, the robot will follow the directions as provided by the PC. The reason I say it is simple is due to the fact that the only sensors involved are the optical encoders, which are not truly accurate devices for precise positioning over longer, irregular paths. There is ALWAYS wheel slippage to consider. Dogs, maybe. Other stuff. This is when things get more complicated and the robot will need more sensors.

    In fact, perhaps another microcontroller will be required merely to handle sensor input. Low-level decisions based on this input might be handled on board the robot. Higher level decisions would be made by the PC (or, perhaps a rack of 1u machines!). The trick is to let microcontrollers do what they do best and larger scale computing equipment do what it does best. The microcontroller should not make sophisticated decisions and the PC should not make low-level decisions.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • uptonryanuptonryan Posts: 28
    edited 2009-03-31 15:45
    Bill,

    Slippage is a very interesting topic. Mapping the location of the robot by the robot is a major problem and was in fact what my thesis was on. My thesis used a radial function(sort of like a neural network) for path planning of an autonomous robot. It wasn't actually a solution I wanted to do but non the less it still won 1st prize at the IEE student paper prize night beating three other universities.

    You mentioned that you use optical encoders for positioning your motors. I was also thinking of hall effect sensors, tilt sensors and ST has just produced a SMD chip the FC30, mainly used in mobile phones to tell the xyz orientation of the phone.

    I know that GPS controlled robots are very successful in orienting themselves.

    But when I think about the human brain I know I don't have a GPS inside my head (although some birds do sense the earths magnetic field) and I am certain I don't use optical encoders or hall effect sensors to locate my limbs. I think I use a complex pattern recognition neural networks to position myself in space. My brain uses a combination of sensor information from vision to tilt sensors in my ears to draw a model map of the world. My brain then does prediction in the past and future based on this model in order to refine it. Then hill climbing algorithms of some sort are use to optimise this model for certain outcomes.

    How do you think we orientate ourselves?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton

    Post Edited (uptonryan) : 3/31/2009 4:03:29 PM GMT
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-31 16:46
    Ryan--
    How do you think we orientate ourselves?
    Like you said, my brain uses vision and my inner ear for both tilt and other positioning input. Additionally, there is an extremely complex mechanism that starts at the soles of my feet and terminates at the top of my head and includes my limbs. This mechanism also provides some input into positioning.

    Using all that, this is how we navigate: Dead reckoning with constant negative feedback. I see a piece of trash in my yard and I set out to pick it up. Every step of the way I refine the error in my positioning/navigation until·I finally close in on the offending trash. Robots need to do the same. All the sophisticated position-determination hardware and software in the world can't match the system I just described.

    I did some interesting theoretical work with a friend of mine on a position-determining system back in the late 70s. 1979, I believe. We never actually built anything, we just developed the math (rather simple) behind an idea I had. Years later, the same idea was used to make GPS work. But, with multiple beacons, GPS is far more accurate, relatively speaking. My idea was dead-on because all it ever consisted of were some equations on a piece of paper. However, if one is willing to introduce fixed beacons seperated by known distances, then robot navigation might become somewhat easier. It would be fun to try in a fixed environment. I don't think it would be too practical, otherwise.

    Anyway, my answer to your 'how do we navigate' question is by dead-reckoning with constant negative feedback.

    Sounds easy.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • uptonryanuptonryan Posts: 28
    edited 2009-03-31 17:58
    Bill,

    It's more complex than that. If for example that trash was blowing about in that back yard in a circle you could plot the trajectory of that trash and predict its movements. If the trash blew over a wall into a neighbours yard you wouldn't bang your head against the wall in the forlorn hope of finding it again you would realise an alternate solution and move on not get stuck in a corner.

    If you lost the use of your leg or arms you could compensate and still pick up trash.

    The reason you can do that and robots can't is that you are concious of your enviroment and your conciousness is a result and part of the environment you are in.

    This discussion probably speaks more about our hygine with trash in your backyard and ants on my wall but the other day a trail of ants invaded a wall at my house and spread out in a line. I had some poison spray handy and decided to spray to see what they would do.

    So I sprayed at the point where they had entered, killing two or three and waited to see what the other ants would do. I think ants orientate themselves using chemical markers (simular to GPS markers) on the ground so removing the chemical marker meant they where lost.

    Initially the ants seamed to react in different ways. Some turned around on the chemical marker and went back the way they came. Some stood still as if they were thinking or in shock and others seamed to wander about aimlessly looking for a path back to relevance.

    After a while I gues the wandering ants where successful as they had re-routed around the posion patch and there was a line of ants following an alternate route.

    All of this complex behaviour is evident in an animal a few millimeters across. Amazing

    I suspect the problem with robotics in its current form is that swarm technologies, that the ants use are not followed. Robots are currently seen as isolated from the environment and not part of it. Robots do not model there environment. Robots do not learn or evolve. Robots can not predict or experiment. I beleive artifical cognition is a function of the system that it is operating in and that its not until robotic intelligence algoritm are environmentally matched that we will see real progress.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-31 18:47
    Ryan--
    It's more complex than that.
    We do not disagree. However, all your correct (in my opinion) hypothesizing does is add additional "CPU" power to a highly developed navigation system based on dead reckoning and negative feedback, with negative feedback playing the predominant role. It would certainly be neat to somehow incorporate one of those CM-1K chips and apply·it to a problem such as this! You would need a high speed link to a real healthy computer to run the software and I haven't a clue how one might get the bit pattern into the chip.

    I have played with ants a lot, myself. They are truly amazing creatures.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • uptonryanuptonryan Posts: 28
    edited 2009-04-01 03:54
    Bill,

    This is a great thread

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton

    Post Edited (uptonryan) : 4/11/2009 4:57:45 PM GMT
  • uptonryanuptonryan Posts: 28
    edited 2009-04-11 16:54
    Probably an easy ·question,


    How do I get the SX28 chip to run without the SX-Key?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
Sign In or Register to comment.