Progress at last

No luck yet with the FTDI cable. But at least I got it with the Bus Pirate!

So:

No LEGO Hub here, just my laptop, the Bus Pirate and the LEGO BOOST Interactive Motor.

Wiring from the Bus Pirate to the Motor:

      • GND -> Pin 3
      • 3V3  -> Pin 4
      • MOSI -> Pin 5
      • MISO -> Pin 6
  • Setup:

Connect the Bus Pirate to the USB port, should show up as ‘/dev/ttyUSB3’.

Access the Bus Pirate with a terminal program like picocom:

picocom -b 115200 /dev/ttyUSB3

Send this commands:

‘m’ to choose mode

‘3’ to choose UART

‘9’ to choose 115200 bps

‘1’ to choose 8 bits without parity (8N)

‘1’ to choose 1 stop bit (so 8N1)

‘1’ to choose receive polarity as Idle = 1 (usual TTL levels)

‘1’ to choose output type ‘Open Drain (H=Hi-Z, L=GND)’

Now that the Bus Pirate is in UART mode:

‘W’ to turn Power Supplies ON (3V3 and 5V pins)

‘P’ to turn Pullup resistors ON

(1) to put the Bus Pirate in ‘Transparent bridge’ mode

‘y’ to confirm

Now quit the terminal (thats Control+A+Q for picocom) and use a serial sniffer like jpnevulator:

jpnevulator -i 10 --tty /dev/ttyUSB3 --read

We should now receive continuous ’00’

Then send the AutoID sequence to the Motor and after that keep sending ’02’ every 100 ms:

#!/usr/bin/env bash

echo -e -n "\x54\x22\x00\x10\x20\xB9" > /dev/ttyUSB3

for i in {1..1000}
do
    echo -e -n "\x02" > /dev/ttyUSB3
    sleep 0.1
done

Sometimes this doesn’t work at first and we just receive a sequence of

C0 00 3F

But aborting the script and trying again will get us:

D8 00 00 00 00 00 00 00 00 27

and if we turn the axle by hand a bit (first clockwise then anticlockwise):

D8 00 01 00 00 00 00 00 00 26
D8 00 01 00 00 00 00 00 00 26
D8 00 02 00 00 00 00 00 00 25
D8 00 02 00 00 00 00 00 00 25
D8 00 02 00 00 00 00 00 00 25
D8 00 02 00 00 00 00 00 00 25
D8 00 03 00 00 00 00 00 00 24
D8 00 03 00 00 00 00 00 00 24
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 04 00 00 00 00 00 00 23
D8 00 03 00 00 00 00 00 00 24
D8 00 03 00 00 00 00 00 00 24
D8 00 02 00 00 00 00 00 00 25
D8 FE 01 00 00 00 00 00 00 D8
D8 FE 01 00 00 00 00 00 00 D8
D8 00 01 00 00 00 00 00 00 26
D8 00 01 00 00 00 00 00 00 26

If  I stop sending this ’02’ every 100 ms the Motor stops sending the encoder status and returns to ’00’. It also looses it’s current state if I don’t restart the whole script soon enough (or just start ’02’ again).

The BitScope logic analyzer wasn’t a great help (except for the timings). I had much more success using the Bus Pirate in ‘Transparent Bridge’ mode to capture each wire of the motor.

Now the reason I cannot replicate this is the FTDI cable is probably the lack of pullup resistors since I’m using a Sparkfun Beefy 3 with an internal PSU that should give enough current to the 3V3 pin. But the Motor also has its own internal pullup and pulldown resistors so this shouldn’t be a problem. is still unknown. Reading the Bus Pirate documentation using the pull up resistors should make no difference because I would also need to manually tie the pull up voltage to 3V3… and I didn’t. Probably the Hi-Z (high impedance) state of the output pin has some importance.

Have to try the FTDI cable again.

Edit: although documentation states that the Bus Pirate pull up resistors also need a manual connection to 3V3… I only have readings when activating the pull ups. And I do have a BP 3.6 board. Go figure.

Edit #2: added “-n” to the test script to prevent sending a New Line (‘0Ah’)

Edit #3: turns out it has nothing to do with pull up resistors or Hi-Z modes… when using picocom to configure the Bus Pirate it changes ‘/dev/ttyUSB3’ to raw mode and leaves it on that mode when quitting… so I can now use jpnevulator to capture all messages from the motor.

 

Series Navigation<< Device 09FTDI adapter working… sometimes >>

Deixe uma resposta

O seu endereço de email não será publicado. Campos obrigatórios marcados com *