Finding out that Hitechnic NXT Touch Multiplexer can not be used with LEGO EV3 controller and EV3 Touch sensors, I tried to find out why.
Opened up the cabinet of the Multiplexer and only found 4 resistors, so it must be analog sensor. Also the NXT Touch sensor and the EV3 Touch sensor are different.
The NXT Touch sensor switches pin 1 and pin 2 , the EV3 Touch sensor switches pin 4 and 6. I tried to calculate a different resistor network, but that failed.
So only a small micro controller could help,
I drilled out and filed a rectangle with the size of a the Wattuino 5V 16mhz 328PB Arduino controller and connected some wires and 4 2K2 resistors. see pictures
Next thing was the write some Arduino code for the 328PB and make it an EV3 Uart Sensor. EV3 Uart sensors can be easy used by the EV3-G software, but also the LEGO or EV3dev Python software.
The Uart emulation hardware library made by Lawrie Griffiths I used, can be found at:
For the EV3-G software I made a Touch Mux Block.
Why I used a Wattuino 328PB, because there are library's for the second serial port, second I2C port and second SPI port, In this case a Polulu A-start 328PB will also do. They only support a second serial port, what I used for the EV3 Uart communication. Of course a normal Pro-min will do, if you use softwareserial for the EV3 Uart communication and use the Uart emulation soft library. Not implemented in my Arduino code. I use hardware serial 1.
The connections of Serial1 of any other 328PB board are on a different positions.
Warning:
Don't connect the power supply's of the EV3 and the USB TTL serial breakout at the same time. Disconnect the V+ of the USB TTL serial breakout to the 328PB board and plugging the EV3 to the Touch Mux. The EV3 will power the micro controller.
I found DATA32 and DATAF bugs in EV3UARTEmulationHard.cpp and EV3UARTEmulationSoft.cpp and change the code.
The
conversion in DATA32 from long to array of bytes is wrong, so also the DATAF is wrong, because that uses the DATA32 send.
Code was:
void EV3UARTEmulation::send_data32(long l) {
byte bb[4];
bb[0] = l & 0xFF;
bb[1] = (l >> 8) & 0xFF;
bb[2] = (l >> 16) & 0xFF;
bb[3] = (l >> 24) & 0xFF;
send_cmd(CMD_DATA | (2 << CMD_LLL_SHIFT) | current_mode, bb, 4);
}
I changed it into:
void EV3UARTEmulation::send_data32(long l) {
byte bb[4];
bb[0] = l & 0xFF;
bb[1] = (l >> 8) & 0xFF;
bb[2] = (l >> 16) & 0xFF;
bb[3] = (l >> 24) & 0xFF;
send_cmd(CMD_DATA | (2 << CMD_LLL_SHIFT) | current_mode, bb, 4);
}
Future:
In my next project I will show you how to upgrade the boot loader of the Pololu A-star 328PB and use both I2C and SPI ports and also use the 3v3 12 mhz and 5V 20 mhz versions. Or any other Chinese 328PB microcontroller.
Comments
Please log in or sign up to comment.