Go Down

Topic: Meccano MAX and Arduino (Read 4486 times) previous topic - next topic

mrdreambot

#30
Aug 10, 2018, 04:38 am Last Edit: Aug 10, 2018, 04:38 am by mrdreambot
The Face is the only device in the chain. Maybe we can optimise a bit by communicating to 1 device instead of 4, no response from non-existent devices anyway. This means that: ((6 + 1) + 18) bytes x 10 bits/byte x 430 us/bit = 107,500 us or roughly 110 ms meaning you can update the Face 9.3 times/sec. With this optimisation, you may not need a dedicated microcontroller for the face if you only need to update the Face 2 or 3 times a second.

mrdreambot

Tested it. The proposed optimization does not work. The devices will not respond with the device type unless all 4 potential modules on the chain have been polled even though there is only 1 device on the chain.

mrdreambot

#32
Aug 11, 2018, 02:00 am Last Edit: Aug 11, 2018, 02:12 am by mrdreambot
Here is a video on scrolling text to the left at the fastest achievable speed on the MAX. It ties up all resources on the Arduino UNO.

Video too big to upload here. Watch it here instead: https://youtu.be/8_z30KEClWs

bmd1103

I wondered about the need to address all 4 positions on the chain ...

I'll need to look at the data stream when the default pattern is being displayed - that seems to update quite quickly.  I on't remember there being any serial transmissions between the graphics. I'm using Serial1 and INT3 on a Mega - the Nano also has a serial part apart from the USB so may be able to use that.

mrdreambot

Sending of image from Arduino to Face is not using serial connection. Serial connection can be used like you did in the 6-byte polling of the devices. You are using interrupts to receive data back from the devices. And you can also use interrupts to send data to the Face. Your Arduino Mega has 4 serials which are sufficient to communicate with 4 chains in the MAX. I don't have a Mega, only an UNO and I have to use bit-banging to do all 3: polling devices, reading 1-byte responses and sending image to Face. Using serials and interrupts is more efficient in using resources but more difficult to program and debug. On the other hand, using bit-banging is not making efficient use of the resources.

bmd1103

Even with a Mega I think I'll need a dedicated processor for the LED array to get reasonable performance. The 140 us time interval isn't a lot to do much other processing for the array, and the 3 extra serial ports will allow a LED array and a maximum of 8 other devices.  With 2 smart motors and the IR sensor (thanks for that - I don't know where I got the ultrasound idea from!) and 4 servos, the Mega is going to be a bit limited in what it can handle.

Never mind - at least we now know some of the limitations to be dealt with.  I still think there is quite a bit of potential with the MAX, even with the mix of protocols.  I think I'll have a look at what's involved in interfacing other devices to the protocol while I can't get my hands on the hardware.


mrdreambot

#36
Aug 12, 2018, 12:26 am Last Edit: Aug 12, 2018, 06:50 am by mrdreambot
Back to my optimization proposal: I found that initially you need to poll all devices until you get the Face to respond with a device type 6. After that, you can just poll the face by itself without polling the other 3 non-existent devices: 1, 2 and 3. The original savings calculation is still correct. The scrolling text is much smoother and twice as fast as before.

When you are back home having access to your hardware setup and oscilloscope/datascope, could you investigate the following please:

1) IR - at one time, I was able to read the distance by issuing the 0xa0 command to the device and it responds with a value. And I can map the response using a formula to get the distance. I forgot which command has to precede that. But now, I cannot repeat it anymore. Command 0xa0 always returns the same value! Could you investigate what is the command sequence that gives a reliable reading? This one is not as important as the next item because I am planning to dump the MAX IR sensor and use more than 1 Sharp IR Sensors or Ultrasonic sensors in its place. It is such a simple sensor and I don't want the protocol overhead. The replacement sensors are easy to program using Arduino. And I am planning to add a camera to MAX to support computer vision control. Will talk more about this and remote control via WIFI later.

2) The MAX motors - you identified the forward and backward commands. Are there other commands eg, controlling the speed, stop, etc. It appears that if you don't send them forward/backward commands for a while, the motors will stop. There seems to be several commands that stop the motor. I am using 0x30. I have to retest this.

mrdreambot

Here is a video showing control of the Meccano MAX's Face, Motors and Servos using an Arduino UNO.

mrdreambot

Submitted this project to hackaday.io. You may follow it to see my progress.

bmd1103

I've started to look at what's involved with the Nano for this application.  One slight complication - the Nano doesn't have separate serial and monitor pots as I supposed, so I have to use Software Serial.  I've modded the standard SS library to handle the 8N2 serial format and will try it out when I get home next week.

mrdreambot

Or you can use your Nano and my Arduino Library for Meccano MAX which uses bit-banging instead of a com port to control MAX's face. The com port can then be used for the serial monitor. ;-)

And if you have time, have a look to see how to consistently get the IR sensor to report the distance (value returned by sensor and the distance is not a linear function but we can work it out). And also if there are commands to change the speed of the motors or keep the motors running without having to periodically send them a command.

Getting home sick?

bmd1103

Looks like I've got a month's worth of things to do when I get back ...

btw, I've just found https://github.com/anotherAlex154/MeccanoidForArduino which might be worth looking into - haven't had a chance yet. Perhaps a joint effort may be in order.

mrdreambot

I've seen it. You should look at my Arduino Library which is designed for the Meccano MAX instead of the Mecanoid. My library contains an example which exercises all devices except the IR sensor. Run it using your Nano and see how it works.

bmd1103

Hi mrdreambot,

I'm back in action.
My first activity has been to look at the signals at low level, and I've had a couple of surprises.  I wrote an app for the Mega that just looks at the times between transitions on the signal line between the Meccabrain and the display module.  I had to use the Mega as there is a LOT of data to be stored - upwards of 2000 items to get useful results.

I first ran the program looking at the start-up sequence - see the file.  (I've deleted a lot of repeats to save space, but nothing of significance.)  I can't see anywhere in there that is a true serial sequence of FF 00 FF 000 FF 00.  There is also no serial transmission between the blank screen for startup and the default sequence.  The different sequences for the various forms of the default follow on one from the other with no serial message between them, which is in line with what I see  with the oscilloscope.

I also managed to get a printout for a change in display using the programming mode to go from LOL! to BYE.  Again, there is no indication in the timing of any serial strings between the two.

I'm currently working on getting the Nano to go - so far I've managed to get a software serial port running with the 2 stop bits needed, and am looking at how to connect up the hardware.

bmd1103

btw, your timings in #29 are based on 10 bits/bye.  There are only 8 bits/byte in the face display.  There are 6 'ticks' needed for the preamble: 18 8-bit bytes at 3 'ticks'/bit = 18 x 8 x 3 = 432 'ticks' for the display itself: and 4 more ticks needed for the stop bit -  a total of 442 ticks.  At 140 us /tick, that is 61 ms - about what I see on the oscilloscope display.  The original has about 32 ms between successive writes to the display - so we should be able to get better than 10 updates/second.

Go Up