Shop OBEX P1 Docs P2 Docs Learn Events
Problem with communication between BS2px and SX28 — Parallax Forums

Problem with communication between BS2px and SX28

real_polyfimosreal_polyfimos Posts: 12
edited 2010-07-14 14:41 in General Discussion
Hallo, to all of·you.
I would be very thankful to anyone who could help me make a sx28 chip communicate with a BS2 stamp. I know·that this is silly for a lot of guys in these forums, but I am not experienced in assebly programming.
First of all,· I'm·writing my thesis this time and because I love the BS2 family chips, I decided to·use a BS2px processor along with a BoEBot style robot to path plan it.
Well, I have tried one million ways to tune the wheels to achieve·aqual speed·(including the PWMPAL, a custom LM556 driver and off course the classic PULSOUT - all these methods where failed because when I look the signals in the oscilloscope, I do not have the resolution I want to tune the wheels)
I had also bought the SX programming kit and for my last hope, I tried to program the SX28 chip, and I was surprised with the results. But unfortunately, even though I have managed to tune the wheels with plenty of accuracy - I couldn't believe it, I need to use it as a slave (only as a motor controller) device to the master BS2px. I have searched very hard these days this forum, but as I told before, I am not experienced in assebly. So,· I would appreciate if· someone could help me with this project.
I need to transfer a byte from the BS2px and then the SX28 run the motors. I have only 5 cases of movements. 0-servos stay still, 1-move forward full speed, 2-move backwards full speed, 3-spin·right half speed, and 4-spin left half speed.
So, the byte will take a value·0 - 4 and then the corresponding code will handle the motors. The SX PULSOUT has given very good results to the oscilloscope , but I need to find some way to get out of the DO - LOOP, and this is my problem. And of course a way to transmit the byte from one side to another.
Well, any who wants to help is welcomed, thank you in advance.

Comments

  • ZootZoot Posts: 2,227
    edited 2010-07-13 01:47
    If you're not super comfortable with assembly, why not just use SX/B 2.x for your SX application (see the download thread at the top of the SX forum main page). This will let you use "Stamp-like" commands like SERIN and SEROUT for communication.

    For *any* serial commands, or accurate PULSIN/PULSOUT type commands, you *must* use a resonator, crystal or TTL clock with the SX. The internal 4mhz oscillator is not accurate enough for reliable serial communication.

    For your do/loop issue, you will not hae an easy to "break out" without using serial routines in an Interrupt Service Routine (ISR), so that the serial input/output happens invisibly in the background.

    If you have pins to spare, you could use another pin on the Stamp and the SX for a pseudo busy/flow-control signal (i.e., the slave could manually poll the pin and if it changes state, then you could break out of the loop, etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    create bitmap data tool: 1uffakind.com/robots/povBitMapBuilder.php
    resistor ladder tool: 1uffakind.com/robots/resistorLadder.php
    convert images to ascii art: 1uffakind.com/apptoys/convtoascii/
  • real_polyfimosreal_polyfimos Posts: 12
    edited 2010-07-13 10:31
    Thank you for the reply. It is very interesting the idea with a pseudo trigger. Thank you. By the way I have found a code with·which I·can use at least wiring instead of communication (thankfully, I have some pins available) from the book : Programming the SX Microcontroller, Gunther Daubach, p.430 and I made some modification on it, but when I execute it, the waveforms on the scope have crazy attitude. Probably, it has to do something with the timing, I don't know. Well, I'm going to post it, if anyone can check it. As for the resonator, I have those 4MHz and 50MHz that come with the programming kit. Which should I use best and which should be the directive in the beggining of the code, and should I use a 10K resistor as I saw it written at the

    Parallax, Inc. · Page 177 :SX-Key/Blitz Development System Manual 2.0 ?

    Thank you in advance.

  • ZootZoot Posts: 2,227
    edited 2010-07-13 17:43
    Not sure about "crazy attitude" -- a schematic might help there.

    However, I don't see any debounce in your buttons?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    create bitmap data tool: 1uffakind.com/robots/povBitMapBuilder.php
    resistor ladder tool: 1uffakind.com/robots/resistorLadder.php
    convert images to ascii art: 1uffakind.com/apptoys/convtoascii/
  • real_polyfimosreal_polyfimos Posts: 12
    edited 2010-07-13 21:18
    Sorry, I forgot to tell that I replaced the buttons with I/Os from the stamp side, so I could control the inputs of the SX. But I did what you suggested and it worked perfect: I wrote a program in SXB and also I added an input to play the trigger role. And everything is fine. I'm going to post the code a little bit later for anyone who 's interested and may have the same problem with me. If you check it, any suggestions·for optimization would be very welcomed. Thanks again.
  • ZootZoot Posts: 2,227
    edited 2010-07-13 23:01
    Awesome. Glad it worked out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    create bitmap data tool: 1uffakind.com/robots/povBitMapBuilder.php
    resistor ladder tool: 1uffakind.com/robots/resistorLadder.php
    convert images to ascii art: 1uffakind.com/apptoys/convtoascii/
  • real_polyfimosreal_polyfimos Posts: 12
    edited 2010-07-14 14:41
    I'm posting the code that worked out. In this way, someone can parse till 256 orders to the SX, by assigning an order to each number. Enjoy! Any improvements, are welcomed.
Sign In or Register to comment.