Shop OBEX P1 Docs P2 Docs Learn Events
How do I get the SX28 chip to run without the SX-Key? — Parallax Forums

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

uptonryanuptonryan Posts: 28
edited 2009-04-17 04:03 in General Discussion
Probably an easy ·question,


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

Ryan

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

Comments

  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-04-11 17:17
    There's really no magic: you need to have a clock source and speed defined. Here's the header for a program I was just looking at:

    ID              "SIRCS"
    
    DEVICE          SX28, OSCHS2, BOR42
    FREQ            50_000_000
    


    In my projects I tend to use a 50MHz resonator (you can get them from Parallax).
  • uptonryanuptonryan Posts: 28
    edited 2009-04-11 17:22
    I should have mentioned I'm using the SX Tech Tool Kit. Is the Tall thin resonator the 4MHZ one or the short and wide one?
    My progra headers look like this is there any difference?

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


    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • uptonryanuptonryan Posts: 28
    edited 2009-04-11 17:41
    OSCHS3 High speed crystal/res., 1MHz…75MHz *
    Apparently


    OSCHS2 High speed crystal/res., 1MHz…50MHz *
    OSCHS1 High speed crystal/res., 1MHz…50MHz *
    OSCXT2 Normal crystal/res., 1MHz…24MHz *
    OSCXT1 Normal crystal/res., 32kHz…10MHz *
    OSCLP2 Low power crystal/res., 32kHz…1MHz *
    OSCLP1 Low power crystal/resonator, 32kHz *
    OSCRC External RC circuit

    OSC4MHZ Specifies internal oscillator @ 4MHz
    OSC1MHZ Specifies internal oscillator @ 1 MHz
    OSC128KHZ Specifies internal oscillator @ 128 kHz
    OSC32KHZ Specifies internal oscillator @ 32 kHz


    I think this should help

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-04-11 18:20
    The resonators have their frequency printed on them -- though you might need a magnify glass and bit of light to read it. I tend to use XT1 for 4MHz, XT2 for 20MHz, and HS2 for 50MHz. Others more experienced than me might give different guidance.
  • uptonryanuptonryan Posts: 28
    edited 2009-04-12 04:26
    It is acting wierd.

    It works with 4 MHZ and key connected and wide flat resonator and OSCXT2.

    When I remove the key it doesn't work

    When I set it to internal resomator "OSC4MHZ" it doesn't work with or without key.

    When I try the other resonator it doesn't work with or without key.

    When I set it to 50MHz and "OSCHS1" it doesn't work with or without key on either resononator.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-04-12 15:56
    Can you post your code for review?
  • uptonryanuptonryan Posts: 28
    edited 2009-04-12 15:58
    '==========================================================================
    '
    ' 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
    '
    'OSCXT2 externl 4
    'OSCHS2, exteernal 50
    'OSC4MHZ
    DEVICE SX28, OSCHS1, TURBO, STACKX, OPTIONX
    FREQ 50_000_000
    ID "Servo"

    '
    ' IO Pins
    '

    SOut PIN RA.3 OUTPUT ' output to pololu

    '
    ' Constants
    '

    Baud CON "T57600" '"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
    '

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

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

    '180 degrees
    Move_Servo_Byte1:
    DATA $00 '0
    DATA $00 '2

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

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-04-12 19:43
    I don't know if this will make a difference but you should set the TX line to the idle state (1 for true) for a few milliseconds before attempting to contact the slave -- this will let the serial buffer on the other side get settled (and the device may need some start-up time). When you make an SX pin an output with the PIN declaration it is an output and low which can look like a start bit to the other side and create false byte on the line; again, by making the TX line high for a few milliseconds before attempting to do real comms you can clear the "false" bit/byte.
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2009-04-12 23:44
    In your post you specify a 4MHz resonator, yet set FREQ to 50MHz in the code. This could be a problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thomas Talbot, MD
    Gunpowder, MD, USA
  • uptonryanuptonryan Posts: 28
    edited 2009-04-13 05:28
    The code specifies 50MHz because I was experimenting with it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • PJMontyPJMonty Posts: 983
    edited 2009-04-13 23:55
    Ryan,

    Are you re-programming it using the Run->Program option before removing the SX-Key? This is also done using the keystrokes CTRL-P.

    If you have simply programmed it for debug and then remove the SX-Key, the project will not run, as the SX-Key is expected to supply the clock and interact with the SX chip.

    Thanks,
    PeterM
  • uptonryanuptonryan Posts: 28
    edited 2009-04-15 14:13
    Yes I have this is weird

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • uptonryanuptonryan Posts: 28
    edited 2009-04-15 15:42
    I think it is a power issue or clock issue. It works when connected via SX-Key to usb to computer but as soon as the usb connection is broken it stops.

    It could be that the removal of the usb cable drops the power supply to the SX Tech Tool Kit and so affects the shape of the bnits goping across to the pololu chip somehow.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2009-04-16 14:50
    Hello Ryan,

    Have you done any other projects with the SX chip to confirm your setup it working? The SX processors are pretty robust chips and shouldn't be this much trouble to get working.

    To check out your SX28 to see if it is running without the SX-Key attached I would make a tiny program to blink an LED and program that into the chip. Just add an LED and current limiting resistor on one of the unused pins. If you use SX/B you should be able to try the different clock settings and if you use the PAUSE to define the delay it should work the same no mater what frequency you select. A short example is in the SX/B help file under PAUSE

    Flash:
    DO
    LOW RC.0
    PAUSE 1000
    HIGH RC.0
    PAUSE 1000
    LOOP

    If the LED blinks then you know the processor is working and that your clock is working too. As someone mentioned make sure you program the chip before removing the key otherwise it will leave some of the debugging code in the chip. If this doesn't work then we'll need to troubleshoot your setup to see where the issue is. Once that is resolved then we can see about moving on and getting it to work with your servo controller.

    Robert

    Post Edited (RobotWorkshop) : 4/16/2009 4:05:24 PM GMT
  • uptonryanuptonryan Posts: 28
    edited 2009-04-16 15:36
    Hi Robert,

    Great suggestion. I followerd it using the code below.

    DO

    MOVE_Mini

    TOGGLE Led
    PAUSE 100

    LOOP

    Where MOVE_MINI sends commands to the pololu to move the servo back and forth.

    When I Connect it to the PC via SXKey and USB the servo motors works and the LED blinks.

    When I disconnect the sxkey and usb the LED still blinks but the servo motors stop.

    I think this proves the fault is with the pololu chip or more precisely the connection between the pololu chip and SXKit. The polulu chip may be drawing cxurrent from the SXTech kit via the connection somehow and when the powered usb is disconnected this changes the signal from the sxkit to the pololu enough for the pololu to stop working.


    I brought and oscilliscope today and hopefully when hook that up that should tell me what the waveform looks like. I was thinking if I connect a 100pf cap and 100 ohm resitor in series across the pololu logic input and pololu ground that may clean up the signal. I may also twist wires together to stop them acting like antennas.

    What do you think?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Upton
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-04-16 16:10
    The USB-SXKey is not providing an power to your circuit. I'm guessing that you don't have a stable clock source connected to the chip; when the Key is connected a stable clock is there; without it you're ragged. The LED blinking after the disconnect of the Key is evidence that the chip is running -- that the Pololu is not responding means the serial bit rate is bad and you should be able to see this with a 'scope.

    BTW, for 50MHz I tend to use OSCHS2, have found other settings (with the resonators I use) don't work well.
  • uptonryanuptonryan Posts: 28
    edited 2009-04-16 16:31
    HA HA Success. I got it to work by connecting the grounding wires of the SX Kit and the pololu chips together. I think they where floating at different grounds and this was throughing the connection between them out.

    I really should wire this properly. Any suggestions?

    Here is a picture of setup dodgy as it is (but working)


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

    Post Edited (uptonryan) : 4/16/2009 4:45:35 PM GMT
    1296 x 972 - 229K
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2009-04-16 18:13
    Hello Ryan,

    The USB SX-Key is powered from the USB port so it shouldn't be causing any power issues. On a side note, the orginal SX-Key (Serial based) required that your target system supplied 5V to power the SX-Key. Since you are using the USB version I doubt the SX-Key is causing any power related problems.

    It's cool that you were able to add the LED which confirms that the SX28 is indeed up and running. Now it is a matter of troubleshooting the connection to the polou servo controller. There are some other questions I have about your setup.

    - How are you powering the polou servo controller? Is it powered from your SX-board so they share the same logic supply?

    - Are the SERVO's connected to the logic supply or do they have their own power source? Servo's can draw quite a bit of power and need an adequate power source with good filtering or it may interfere with the operation of the CPU.

    - How is the connection done between the SX28 and the servo controller? Is it a direct logic level connection or is there anything inline? You mention adding a cap to the serial line but I don't see where you would need that. How about pull-up/pulldown resistors?

    - In regards to the servo controller does that have a fixed baud rate or does it 'auto-detect' the incoming data? If it auto-detects perhaps it is making a mistake.

    Robert
  • uptonryanuptonryan Posts: 28
    edited 2009-04-17 04:03
    Hi roboert, the servo motor works stand alone now after I connected the pololu ground and sx ground together.

    >How are you powering the polou servo controller? Is it powered from your SX-board so they share the same logic supply?

    Originally the pololu and sxtech board ground seperately with 7.5V 1amp for the sx and lab power supply for pololu. I then connected the ground of both those boards (but the Vdd is still seperate) and now it all works.

    So there are three power supplies, one for pololu one for sx and one for servos.

    >- Are the SERVO's connected to the logic supply or do they have their own power source? Servo's can draw quite a bit of power and need an adequate power source with good filtering or it may interfere with the operation of the CPU.

    Servos have a seperate power supply

    - How is the connection done between the SX28 and the servo controller? Is it a direct logic level connection or is there anything inline? You mention adding a cap to the serial line but I don't see where you would need that. How about pull-up/pulldown resistors?

    I just ran hookup wire from pin 3 of the SX28 to logic in of the pololu controller. At one stage I had pull up resistors and an led to check coms.

    - In regards to the servo controller does that have a fixed baud rate or does it 'auto-detect' the incoming data? If it auto-detects perhaps it is making a mistake.

    I thought this as well. The pololu has an auto-detect. But it is confusing,It may fix it permanently once it detects it, but this is something that is not clear from the pololu manual or from experimentation. At the moment it seams fixed on 57,600 baud for one mode and 9600 for another mode.

    Eventually I want all this to run from the same power supply. I have brought some capacitors to act as reseviours to do this.

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