Shop OBEX P1 Docs P2 Docs Learn Events
SX/B 16 channel PWM and/or SERVO controller - Page 3 — Parallax Forums

SX/B 16 channel PWM and/or SERVO controller

13»

Comments

  • BeanBean Posts: 8,129
    edited 2006-07-18 10:13
    ahanktcd,
    · You are correct. To use higher baud rates the serial reception would have to be in the interrupt routine.
    · As it is, the interrupt already uses ALOT of the cycles.
    · If you decreased the interrupt rate (which would lower the PWM update rate) you could probably do it.


    [noparse][[/noparse]edit]·
    · I just looked at the code again.
    · The PWM or servo outputs only update at 195 Hz (1950 Baud).
    · So a higher baud rate is not going to make them change any faster.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.


    Post Edited (Bean (Hitt Consulting)) : 7/18/2006 10:20:49 AM GMT
  • SailerManSailerMan Posts: 337
    edited 2006-09-25 01:44
    I hate to bring this thread up again... but I was wondering Bean if you could help me understand the PWM code. I am just begining with SX/B as a matter of fact my Kit is Arriving on Monday and one of the first projects I have set up is a motor controller. I know I can buy one, but I wanted to start from scratch based on the L298.

    Any help you can provide would be appreciated.

    Mainly the ASM code.

    Sailer
  • BeanBean Posts: 8,129
    edited 2006-09-26 02:04
    Sailer,

    The ASM code for that program is kinda hairy because of the requirement that the interrupt routine take exactly the same number of cycles each time through. Because it communicates serially. If you are putting ALL the code in the SX (in otherwords the SX that is generating the PWM is also deciding what the PWM should be) then you shouldn't need the serial comms, so you don't have to worry about the cycle counting.

    Did you by chance order the SX48 proto boards ? If so you are in luck, because they have 2 16-bit timer counters that have a directly hardware PWM output.

    How many channels of PWM do you need ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • SailerManSailerMan Posts: 337
    edited 2006-09-26 15:36
    Bean,

    I am a total beginner with the SX chips..and have no experience with ASM..·and to answer your question I really only need 2 PWM channels for two motors.

    My first project is to create a Motor Controller for the Stamp based on the L298 that is controlled with a Serial command.

    I did not purchase the SX48 Protoboard... I just got the Lite Version. It came with two SX28 Chips. If I had a way to incorporate the SX48 into my own project that would be great but I don't have the equipment soldering SMD.

    Thanks,

    Eric
  • crgwbrcrgwbr Posts: 614
    edited 2006-09-26 16:09
    Hi,

    I suppose this is off topic, but I downloaded this code and I am going to use it in in a motor controller.· But before it would compile correctly, I had to change the variable "count" to "counter", it was recogising "count" as a command.· Has anyone else had to do this?

    Forgive me if this is stupid, I just got my first SX today, I've only worked with the BS2 before.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    NerdMaster
    For
    Life
  • BeanBean Posts: 8,129
    edited 2006-09-26 17:18
    The COUNT command has been added to SX/B after this was released.
    So yes, the variable named "count" will have to be changed.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • SailerManSailerMan Posts: 337
    edited 2006-09-28 12:13
    Bean,

    You asked me some questions and I responded but you never responded back.. Do you have time to help?

    Thanks in Advance,

    Eric
  • edited 2008-08-26 16:02
    Bean (Hitt Consulting) said...

    SEROUT SPin, Baud, [noparse][[/noparse]"!PWM", R1, G1, B1, R2, G2, B2, R3, G3, B3, R4, G4, B4, R5, G5, B5, 0] ' MUST send 16 bytes after "!PWM" 
    
    




    I know I'm resurrecting an ancient thread, but this is a point of confusion at my lab.

    In the code, you specify 21 bytes, "!PWM" + config byte + 16 data bytes. In the quoted example, you only specify 20 bytes. Could you clarify?

    Also, does anyone have any suggestions for forcing Python to write ASCII 0x03 into the config byte (I'm using Pyserial's serial.write() method, which only takes a string)? Or could I force it on the SX board by changing

      GetSerialChar
    
      PWM_Config=SerialData
    
    


    to
      GetSerialChar
    
      PWM_Config=3
    
    



    edit: assuming, of course, that I want to control servos.

    Second edit: According to my 'scope, it didn't work. I'm getting sawtooth-looking pulses 2.5ms apart.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --
    Christopher Agocs
    Georgia Institute of Technology

    Post Edited (Christopher Agocs) : 8/26/2008 4:35:28 PM GMT
  • ahanktcdahanktcd Posts: 8
    edited 2008-09-25 02:42
    I am building a dual H-bridge motor controller project on a PCB. I have 74 and 116 amp P- and N- channel MOSFETs controlled by NPN transistors. What I need is SX/B code to run an interrupt to accept serial data and operate the NPN transistors to run both full H-Bridges.

    I'd like to run somewhere in the 1 to 5kHz range and have control over forward and reverse of both motors while fielding incoming serial data at 19.2kbps or 38.4kbps.

    Is there code out there for this or simple PWM code that I can modify to be a full h-bridge controller, all via interrupts?

    Paul
Sign In or Register to comment.