Shop OBEX P1 Docs P2 Docs Learn Events
serout coms with Meccano™ Smart Servo — Parallax Forums

serout coms with Meccano™ Smart Servo

roadrunner3g.roadrunner3g. Posts: 6
edited 2018-10-05 00:38 in Robotics
I am trying to run the servos with a BS2. They can be daisy chained up to 4 in a row. They require a 6 byte data packet [header,d1,d2,d3,d4,checksum/id]. I am having trouble with the serout command. The Checksum byte is actually comprised of two 4 bit nibbles, the upper 4 bits and the
lower 4 bits. The upper 4 bits are the actual checksum which is calculated based on the
values of Data bytes 1 through 4. The lower 4 bits contain the Module ID number which is
critical to the entire bi-directional data stream.
Each Smart Module receives the entire 6 byte data packet and then passes the exact same
data packet down to the next module. There is no shared data bus. The data going
upstream or downstream must be sent through each Smart Module.
The bits of each byte coming from the MeccaBrain™ are approximately 417us long. A “1”
bit is 417us of HIGH; a “0” bit is 417us of LOW. Each byte has a start bit (Low) and two
stop bits (High). Also, the data bits are sent in reverse order.
To be clear, each data byte looks like this
{LOW, Bit 0, Bit 1, Bit 2, Bit 3, Bit 4, Bit 5, Bit 6, Bit 7, HIGH, HIGH}
And the entire data packet would look like
{0xFF, DataByte 1, DataByte 2, DataByte 3, DataByte 4, Checksum/Module ID}
The baud rate is 2400. I can connect the BS2 to the end of the chain with the mecca brain and get the serin to read the line just fine " SERIN servo,1646, [WAIT ($FF),s1,s2,s3,s4,checksum] " , but can't make the servos work without the mecca brain. The data bytes need a "0" start bit and 2 "1" stop bits. and then there is the checksum/id byte.



Comments

  • BeanBean Posts: 8,129
    edited 2018-10-05 02:29
    I think the problem is that the BS2 only sends 1 stop bit.

    This is not a problem when receiving, but if the servos require two stop bits they may not work.

    I don't think there is a way to send two stop bits, but I haven't used basic stamps in years. Check the manual.

    Bean
  • You cannot change the stop bits in the BS2, but you can add a pacing delay between bytes -- hopefully, the device won't timeout using the pacing delay.
  • the pace thing doesn't work, the data packet is 6 bytes. with a low start bit and 2 high stop bits per byte. I get 66 bits for a packet (including start/ stop bits).

    what is the bs2 stop bit??? high or low???
  • ercoerco Posts: 20,244
    Whit bought a bunch of those Meccano smart servos when TRU folded. Not sure if he got them going or not, but if so, likely with a Prop, not a BS2.
  • BeanBean Posts: 8,129
    edited 2018-10-08 14:10
    roadrunner3g,
    The stop bits are the same state as idle.
    It might work if use a seperate SEROUT command to send each bit. As this will add a slight delay between the bytes.
    You might even have to add some code between the SEROUT commands like "A = A + 0" or something to create more of a delay.

    Extra stop bits are usually used to give the receiver some time to process each byte.

    Bean
  • JonnyMacJonnyMac Posts: 8,912
    edited 2018-10-08 16:29
    the pace thing doesn't work, the data packet is 6 bytes. with a low start bit and 2 high stop bits per byte. I get 66 bits for a packet (including start/ stop bits).
    That seems odd. The stop bit(s) give time for the receiver to store what just arrived. Adding pacing between bytes is like adding extra stop bits. Using a pacing of 1ms at 2400 baud would be like having 3.5 stop bits.
    This was taken from the online help BASIC Stamp online help manual (which I helped create when I worked for Parallax).
    The SEROUT command can also be configured to pause between transmitted bytes. This is the purpose of the optional Pace argument. For example (9600 baud N8, inverted):

    SEROUT 1, 16468, 1000, ["Slowly"] ' baudmode set for BS2

    Here, the BASIC Stamp transmits the word "Slowly" with a 1 second delay between each character. See the table above for units of the Pace argument. One good reason to use the Pace feature is to support devices that require more than one stop bit.
  • Each Smart Module receives the entire 6 byte data packet and then passes the exact same
    data packet down to the next module. There is no shared data bus. The data going
    upstream or downstream must be sent through each Smart Module.
    The bits of each byte coming from the MeccaBrain™ are approximately 417us long. A “1”
    bit is 417us of HIGH; a “0” bit is 417us of LOW. Each byte has a start bit (Low) and two
    stop bits (High). Also, the data bits are sent in reverse order.
    To be clear, each data byte looks like this
    {LOW, Bit 0, Bit 1, Bit 2, Bit 3, Bit 4, Bit 5, Bit 6, Bit 7, HIGH, HIGH}
    And the entire data packet would look like
    {0xFF, DataByte 1, DataByte 2, DataByte 3, DataByte 4, Checksum/Module ID}
  • kwinnkwinn Posts: 8,697
    Each Smart Module receives the entire 6 byte data packet and then passes the exact same
    data packet down to the next module. There is no shared data bus. The data going
    upstream or downstream must be sent through each Smart Module.
    The bits of each byte coming from the MeccaBrain™ are approximately 417us long. A “1”
    bit is 417us of HIGH; a “0” bit is 417us of LOW. Each byte has a start bit (Low) and two
    stop bits (High). Also, the data bits are sent in reverse order.
    To be clear, each data byte looks like this
    {LOW, Bit 0, Bit 1, Bit 2, Bit 3, Bit 4, Bit 5, Bit 6, Bit 7, HIGH, HIGH}
    And the entire data packet would look like
    {0xFF, DataByte 1, DataByte 2, DataByte 3, DataByte 4, Checksum/Module ID}

    Sounds like they worked really hard to lock users in. The Propeller serial object could be modified to match that, but that may not be doable for the Basic Stamps.
Sign In or Register to comment.