Saturday, January 20, 2018

XMSnakeRobot - Review of a possible robot brain - SmartWatch X01S Android 5.1

Our small robots need small but powerful Android devices as a central controller computer ie "brain". We have been using low cost Vodafone VFD 300 SmartPhones but they are a little large and heavy for our new robot designs. Preferably running the same Android OS with the capability of programming in JavaScript using the DroidScript framework. We also need a sideways pointing camera,

The candidate devices are:

"X01S SmartWatch" - currently testing. Good results so far, details below. At 64g it is a little heavy but physical size is good and it has full Android 5.1 features and good performance with 1 Gig of RAM which is better than the 500 Meg of the VFD 300 and the other candidates..

"QW09 SmartWatch" - we have bought and tested a "DZ09" which is the same physical hardware with a "Nucleus" operating system. We were unable to program the "DZ09". We do discover that it has a sideways pointing camera and a weight of only 38g. The more expensive Android version "QW09" has Android 4.4 and 500 Meg of RAM which is low end, but that low weight is a very attractive feature. Possible TODO = buy and evaluate QW09.

"Raspberry Pi Zero" - this is physically larger than the SmartWatches although less weight at only about 10g. We can buy an optional extra camera, only about another 2g,  that attaches with a flexible ribbon cable which can fit robot layout needs. "Pi Zero" can be programmed in JavaScript with a different framework "node.js". The current biggest barrier and still under investigation is GSM communication - ie cellphone data comms which appears to be a complex and challenging exercise involving connecting a GSM modem to a USB port. The GSM modem has a weight of 21g losing much of the "Pi Zero" weight advantage although we have the option of using USB cabling to separate it from the "Pi Zero" and away from the robot "head" to get better weight distribution. Another issue is that microphone, speaker, motion sensors, GPS are all add on extras for the "Pi Zero" where the X01S has them in the package.


X01S in detail.

As a SmartWatch

Before removing the straps and going robot-brain, I did try it out as a wearable.
The X01S works well as a watch and it is a very capable complete SmartPhone. It has a solid metal case which is good for a SmartWatch but not so welcome in a robot brain. I was able to type with my big clumsy finger on a tiny screen while feeling surprised that this was working so well. The improving Google speech recognition is a welcome alternative to typing. Websites are surprisingly readable. Making phone calls and texting is all do-able.

I mail-ordered the X01S from an "AliExpress" seller - "Xiao mi World Store".
Cost including shipping was just under 100 New Zealand dollars which is about 70 US dollars.
On arrival I swapped the SIM card over from the VFD 300 and the X01S was all go with Vodafone New Zealand.

I wanted to get screen lock working with a PIN number. I searched through many options looking for this before finding it under the rather less than obvious "VPN".
That is "Settings" -- "Wireless & Networks" -- "More" -- "VPN"


As a Robot Brain - so not the usual kind of review!

The "DroidScript" framework downloads from the Google Play Store and works fine. DroidScript  remote coding over Wi-Fi from a full size computer works which is an essential need for a small device. All my code created on the VFD 300 SmartPhone copied across and ran on the X01S. I use the HTML hybrid interface coding option which I understand may be relatively high demand for the device, so well done X01S.

Bluetooth, Wi-Fi and GSM Data all perform well.

Removing the straps was a challenge. They are held by what looks like a screw at each end of a rod but there is only one small screw threading into the end of a long rod. I needed to try both ends to find the end where the screw unscrews then push the rod out from there. On pushing the rod out about 3mm it becomes easy to grab and pull the rest of the way.
Then I discovered as is common with SmartWatches that there are antennas in both watch straps. So it was replace the rods then peel the backing off the straps to unstick the antennas. Doing this, one of the antenna wires pulled out of the watch. However GSM, WiFi and Bluetooth are working well with only one antenna so I am continuing with that. (Maybe I have lost GPS? Todo check),

Strap removal is difficult compared to the DZ09 / QW09 design.
If I was to do this again I would cut the straps 33mm from where they meet the device, although this depends on how the device needs to fit into the robot.
My complete strap removal gave a weight reduction from 85g to 64g.

Other robot brain points of interest:
Is it possible to run and/or recharge from the robot power source?
Yes. External power (5V)  is a little unusual being metal touch pads contacted by the USB charger. I would need to make a mock charger but that does look doable. See photos below. The supplied charger unit could become part of a robot but it has magnets in it giving it a relatively high weight of 29g.
The battery weighs 13g so it would be possible to run with that removed and get the unit weight down to 51g. I plan however to keep the battery in the watch for the convenience of being able to work with the watch while the rest of the robot is switched off. Good also to be able to remove the watch from the robot for better access to it for setups and adjustments.

Photos:

Strap removal surgery. Sticky antenna revealed.


Straps removed. X01S with 1 antenna. On the weighing machine.


X01S running my Snake Robot Brain code. That app "XMSnakeBrain" along with other code and designs from the "XMSnakeRobot" open source project is on Github:
https://github.com/manukautech/XMSnakeRobot


X01S, straps removed, showing antenna.
There are 2 buttons and the camera on the right side of the X01S.
The camera lens is in the middle.



X01S with charger unit which also acts as the USB adapter.
The 4 pins are a custom USB connection with the outside 2 pins as GND and V+ (5V).


















Photo taken with the X01S. Street scene.



















Photo taken with X01S. Interior old machinery. Low light, twilight outside.



















Test run of remote control of X01S with "AirDroid" and "AirMirror".
The "AirMirror" window mirrors the app running on the X01S.
There is also a camera window so we can see what the Snake Robot is seeing.
In this screenshot I have a snake robot looking at me.




















Link to X01S on "Xiao mi World Store" as at 21 Jan 2018.
These links change a lot as do the manufacturing runs of changing device designs.
If you are a future reader finding this link dead, you can try searching AliExpress for "SmartWatch X01S".
https://www.aliexpress.com/item/2017-New-3G-WiFi-X01S-Android-Smartwatch-Phone-Bluetooth-Smart-Watch-1-3GHz-Dual-Core-IP67/32825965106.html








Sunday, December 31, 2017

XMRemoteRobot - movement achieved with "inchworm gait"


Snake Robot hardware milestone today -  reliable ongoing operation responding to servo commands. Now we have a testbed, the first programming exercise is the "inchworm" gait which is the simplest of snake robot "gaits".

The biggest challenge in the last 3 days has been the head section intermittently going dead as its Arduino Nano microcontroller resets itself. After a lot of detective work I tracked it down to momentary voltage drops. The power supply to the forward section was through thin wires that gave a voltage drop from about 5.3V to 4.8V. There were extra momentary voltage drops when servos came under load and that caused the microcontroller resets. The fix was to run a second parallel pair of wires, V+ and GND from the regulator on Rib05 to the power board on Rib02. That may not be the full story because adding these similar thin wires resulted in a minimal voltage drop rather than halving the effect as expected. It is therefore a good idea to check sections in detail for an unexpected resistance effect.

Tuesday, December 26, 2017

XMSnakeRobot - waggles its head and tail


Youtube video. Testing starts with hand-typing simple command signals.

XMSnakeRobot - we have digital control - 20 out of 20 servos responding.

Milestone tonight (Tue, 26 Dec 2017).
The snake robot "spinal cord" is working. That is 20 servos are responding to remote signals as planned.

Looking at my previous issues of "rogue" servo movements.

Try changing from Arduino Nano to Wemos D1 - a different microcontroller.
I did that - a major change, and the servo bad behaviour was THE SAME!. This prompted me to look harder at my code. After digging deep I did find a "bug". Coding fix gave a successful system fix.

Working on other issues.

Issue: One Arduino also resets itself when servos encounter loads like lifting the snake robot's head.
That head section has 40cm of thin cables supplying power from the centre of the Snake Robot. These have a significant voltage drop - typically 5.1 volt dropping to 4.8 V with momentarily dropping lower when servo loads kick in. 
I got a small improvement by cranking up the regulator to 5.4V. 
I got a further improvement by adding a 470uF capacitor and 39 ohm resistor to the Arduino Nano power supply cable - all good on individual servo testing [LATER - resets still happening on multi-servo movements trying out movement "gaits"]

Hypothesis: Try the "volatile" coding keyword for my servo array.
Made no difference. Also "volatile" triggered a compile error with the Wemos board. That puts a stop to trying "volatile" because I want to leave the way open to using Wemos boards.

Photo: Snake Robot as at 26 Dec 2017.



















Photo: The Android Smartphone is running app "Serial Bluetooth Terminal" by Kai Morich.
Signal "A2+020" = "Target microcontroller 'A', Target Servo 2, Set to +20 degrees from centre position."



Saturday, December 23, 2017

XMSnakeRobot - HC-05 problem solved - needs clean switch-on

Keywords: HC-05, problem, erratic, will not switch on, fail, dead, intermittent, fault, electronic module.

On changing to an external power supply I found that the HC-05 module would not start when I "switched on" by connecting an alligator clip. Then I observed that if I touched the alligator clip to the battery terminal the HC-05 would switch on OK. But the usual clamping it on - no! After some playful experimentation I found a consistent pattern. The HC-05 needs a definite clean change from off to on. Clamping an alligator clip gives a moment of touching and movement which gives an on-off-on-off-on-off-on way of starting electrical life in my circuit. I should solder a proper switch into the snake robot external power leads. In the meantime I have worked out an alligator clipping action where I open the alligator clip, press one side against the terminal then release the other side to clamp.

Hopefully this helps anyone else encountering this mystery!
What is an HC-05? A small circuit board about the size of a human little finger which gives bluetooth capability to device projects - like a snake robot. More about HC-05 here:
http://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-tutorial/

XMSnakeRobot - Servo issues - 13 good channels - 7 do strange dancing

The snake robot -  (link) see photos here - has 20 servos run from 3 x Arduino Nano microcontrollers. As of today 13 of these are working and 7 are mis-behaving. Most common misbehaviour is:

  • Command servo to turn 30 degrees - it turns more than that.
  • Command servo to return to the centre position - it turns in the same direction as before but to its extreme position.

My Arduino code includes code to return all servos to the centre position on reset. This works.
I have tried swapping servos and found that the behaviour is pin-related rather than servo-related.
All 3 Arduino Nanos have the same "sketch" (program code) and similar servos connected. They are misbehaving on different pins.
One Arduino also resets itself when servos encounter loads like lifting the snake robot's head.
[Later - 26 Dec 2017 - that head section Arduino has 40cm of thin cables supplying power. These have a significant voltage drop - typically 5.1 volt dropping to 4.8 V with momentarily dropping lower when servo loads kick in. Fix was to crank up the regulator to 5.35V (small improvement) and add a 470uF capacitor and 39 ohm resistor to the Arduino Nano power supply cable (complete fix).]

Hypothesis: There is a problem with I2C.
I have been trying I2C for the first time so I have put a lot of time into checking that.
Now I have changed to Serial communications with exactly the same effect continuing.
At least I know that I can get I2C to work!

Hypothesis: Servos can cause electrical interference.
I have tried running an Arduino on a separate battery to the Servo power supply. No difference.

Hypothesis: Arduino Nano work overload.
TODO try the  "volatile" coding keyword for my servo array.
The (link) Arduino Reference "Volatile"  - states:
"volatile" -- "Specifically, it directs the compiler to load the variable from RAM and not from a storage register, which is a temporary memory location where program variables are stored and manipulated. Under certain conditions, the value for a variable stored in registers can be inaccurate."
Emphasis mine!
[Later - 26 Dec 2017 - made no difference. Wemos board (see below) would not compile so "volatile" is eliminated because I want to leave the way open to using Wemos boards]

Hypothesis: The Arduino Nano is simply too low powered to handle the work I am giving it and it is "falling to pieces under the stress". I have found this forum comment:
(link) desmondcorreia (2011) writes:
I have tested each code independently everything works fine but as soon as i put it together everything goes wrong.
Desmond, You sum up my experience so well!
I do have a WEMOS D1 microcontroller where the specs say it runs at 80 MHz which is a good advance on the 16 MHz of the Arduino Nano. I am considering swapping that in. A little challenging with it being a 3.3 Volt system connecting into my very 5-volt-everywhere snake robot.
[Later - 26 Dec 2017 - changed tail section microcontroller from Nano to Wemos, a major change, and the servo behaviour was the same. This prompted me to do another review of my coding and after digging deep I did find a "bug". Coding fix gave a successful system fix.]

That should be enough to be going on with!


Friday, December 22, 2017

XMSnakeRobot - Good news for current draw. I2C partly working

First results from the ammeter on current draw for this design.
0.5 to 1.0 A depending on servo activity which is however low at this early testing stage.
This is good news as it is less than expected.
One concern was that segments as they move would place nearby segments under load and put servos into a "stall" state where they draw 0.6 A. This is not happening like that. What I am observing is servos under load but responding with rapid "buzzing" correction attempts which average out to a much lower current draw.

-----------------------------
In the previous post I wrote:

Searching .. From Arduio forum thread "I2C with internal pullups"
https://forum.arduino.cc/index.php?topic=369003.0
"Koepel" says: "If  an Arduino is Slave, and it has the power turned off, that will keep the SDA and SCL low via the diodes."

"Koepel" is right. Connecting the "slaves" for a complete test setup gets my servos responding to signals sent via I2C. Unfortunately the responses are not 100 percent reliable. One of my 2 "slave" sub-systems is ok on 7 servos out of 8 so I will inspect that servo. The other "slave" sub-system gives a correct response to less than half of the signals I send. These "slave" sub-systems are built to be almost identical and they run on the same I2C common wires so this is a mystery. I plan to continue with I2C by working for half a day focussing on testing servos - then if not reliable it will be plan B which is to replace I2C with Serial and SoftwareSerial.

Signals explained by example:
"A2+030" - Arduino Nano A, Servo 2, set to 30 degrees from centre position.
"B0-020" - Arduino Nano B, Servo 0, set to minus 20 degrees from centre position.
"C5+000" - Arduino Nano C, Servo 5, set to centre position.

I type these signals into an Android Cellphone running a Bluetooth Terminal app. The snake robot receives these on an HC-05 module which feeds them via Serial to "nano" microcontroller "A". If the signal starts with 'B' or 'C' that microcontroller uses I2C to pass them on to the other "slave" microcontrollers. Photos and more details in the previous post:
https://hitechfromlotech.blogspot.co.nz/2017/12/xmsnakerobot-construction-completed.html

-----------------------------
I have done a little speed up of testing by soldering together an adapter cable set to run the snake robot off an external battery or power supply. The internal batteries are model aircraft LiPo types which need careful charging and setup for each working session. It is faster to get into a testing session by simply "plugging it in to the extension leads" (12 V).