Close

Adventures in robotics

olaf-baeyensOlaf Baeyens wrote 10/18/2016 at 21:20 • 1 min read • Like

My adventures in building the Thor robot.

https://hackaday.io/project/12989-thor

Like

Discussions

Olaf Baeyens wrote 08/21/2017 at 21:17 point

Measuring the Nextion 7 Inch display Tx and Rx signals appears to function at 3.3V levels. Maybe someone could check this with an oscilloscope?

See blog post 62 where I measured the analogue signals on my logic analyzer, zoom in on it.

  Are you sure? yes | no

dannyvandenheuvel wrote 08/22/2017 at 01:29 point

I had also big serial issues in the past, did you screen your wires or do you use the included cable? do you have the logic shifter between it? you need it to amplify the signal from the ultraboard to the nextion and in the other direction you have to lower it (thats what the logic shifter is doing). It is working perfect at my configuration. I have used the included cable but I took a screened wires, stript it and used the screening around my wires.

  Are you sure? yes | no

Olaf Baeyens wrote 08/22/2017 at 17:28 point

Hello Danny, the shielding is the first thing I was thinking of. I remembered your warning :-)  But I measured the analogue signals 3.3V at the board itself and they all pass through. I am testing without connected motors.

https://cdn.hackaday.io/images/7693411503347874267.jpg

Top layer is the Nextion 5V part at the level shifter. The bottom part is at the Thor controller pins themselves, not at the level shifter.

When you look at the transmitted data they end on 0xFF 0xFF 0xFF that is correct. The same is true for the start byte 0x65.

Then  you have 0x01 = page,  0x17 = button 23 and 0x01 = button pressed.

The other buttons do get detected so the Tx and Rx loop is functioning correctly.

I do not see any clear noise signal. I think I will need to look into the Nextion code themselves when I have free time.

(I do not have shielded cable here available I will need to get them)

  Are you sure? yes | no

dannyvandenheuvel wrote 08/22/2017 at 01:35 point

Look at these photo, you can see the screened wires.

https://cdn.hackaday.io/images/515501487515479857.jpg

  Are you sure? yes | no

Olaf Baeyens wrote 08/20/2017 at 21:09 point

This Nextion HMI display communication makes no sense when seen on the logic analyzer.  I notice a button press that I did not press when I press a lower button.  I also notice that buttons do get pressed but for some reason the code at the Thor side does not recognize it. Technically the code should work.

I need more time to dig deeper into this when I find more time.

  Are you sure? yes | no

Olaf Baeyens wrote 08/20/2017 at 20:21 point

Interesting, I put a logic analyzer to see what the communication between the Nextion display and the Thor controller is and it appears that it gets the button press received but somehow the code does not function to catch the Dual State button at the Thor controller side. The normal button functions.

  Are you sure? yes | no

Olaf Baeyens wrote 08/20/2017 at 00:51 point

I think I hit a bug in the Nextion editor.

When I use a dual state button then when I press it on, then its "val" change to 1. When I click on it again then its "val" changes to 0. This work correctly inside the Nextion display.

However the Command that is sent to the Arduino stays in both cases "1".  I know that I changed state but I have no idea if the val = 0 or 1.

The other issue with the Nextion Arduino implementation is that I have no access to the Page and Component ID. I have resolved this by inheriting from the component and expose these 2 fields but this is an additional step. I need these otherwise I will need 25 different call-backs.

Challenges, I love them!

  Are you sure? yes | no

Olaf Baeyens wrote 08/15/2017 at 21:09 point

Been thinking about the button interaction.

Currently I have 3 states, disabled, active but not pressed (red) and active and pressed (green). The code to change these colored is programmed into the Nextion HMI. It is there to have a responsive display so you know that you pressed the power on button and not press it twice and power it off again by accident.

However a button pressed on the display does not mean that the button is actively be accepted by the robot controller. I need a way for the robot to send back another state indicating that it is executing it for real.

In addition to that I need another button state that comes from the robot controller that this command is in a failed state or even a waiting to execute button.

I will probably need 6 bitmaps:

Control by the Nextion HMI:

* Disabled button (dark red)

* Enabled button (bright red)

* Pressed button (bright green)

Controlled by the Thor robot controller

* Executing button (bright orange)

* Fail button (bright red with a fail Icon)

* Waiting to execute button (bright orange but with an wait button)

The thing here is a simple operator button that gives enough feedback what the robot is doing. The cool thing about this is that every single button can have its unique fail, waiting, disabled executing state independent of the other.

The other thing I want to have is some watchdog mechanism that can check if the Nextion display is still responsive and not somehow crashed. Or have a lose connection. We do not want the robot to operate and never get the stop command because a wire got lose. Safety must be built into it from the very first line of code.

This Thor robot is big but the software may be even bigger and ready for THORZILLA.

  Are you sure? yes | no

Olaf Baeyens wrote 08/14/2017 at 23:57 point

The Nextion compiler drove me crazy with this code

if (bt1.val==1)
{
  b1.picc=1
  b1.picc2=3
} else
{
  b1.picc=0
  b1.picc2=1
}

It turns out that the Nextion editor has an issue with the "space"

All resolved by just removing the space between the "if" and the "('"
The same for the else, just remove the space.

if(bt1.val==1)
{
  b1.picc=1
  b1.picc2=3
}else
{
  b1.picc=0
  b1.picc2=1
}


  Are you sure? yes | no

Sepio wrote 08/15/2017 at 15:16 point

What a strange way of writing the if and the else. I have never seen that before. Is this a bug in the Nextion Compiler?

  Are you sure? yes | no

Olaf Baeyens wrote 08/15/2017 at 15:23 point

They call it 0.47 so this is still a beta version. Also their documentation is seriously lacking. But the display itself works great.

  Are you sure? yes | no

Olaf Baeyens wrote 08/11/2017 at 18:21 point

Four 4 holidays in a row! This time I promise myself not to get distracted from the Thor project! I promise myself not to build my own reception antenna, nor play with ESP-12, nor eInk panels or boost/buck converters, nor Raspberry Pie or AI! Focus, focus focus....

First priority is give my 3D printer a job to do since I have new firmware, software and I need a protection casing for my Nextion 7Inch display. Also test my 3D printer to see if the new Simplify 3D and latest firmware update solves my warped printing problem.

  Are you sure? yes | no

Olaf Baeyens wrote 07/29/2017 at 20:59 point

Thanks to Danny's feedback I now am able to program the Nextion HMI display easier.

You get 2 background, one with all buttons disabled and one with all buttons enabled. Now you can drag and drop buttons on the screen and mark them as "Crop Image". Depending on the state of the button the background or foreground is shown for that cropped area.

The screen I develop now is a diagnostic screen first, a lot of buttons to put on that screen. Still figuring out the design.

Initially I was disappointing in the Nextion display because it was not responding to my finger presses but works with a pen. But now I am glad because I do notice a lot of accidental swipes and presses on my Smart phone. It would be dangerous if the wrong button was pressed with a fat finger and start to run the wrong motor.

  Are you sure? yes | no

Olaf Baeyens wrote 07/29/2017 at 20:26 point

Got sidetracked again, this time I built my ASD-B flight tracking receiver with the firmware of FlightRadar24 on it. Raspberry Pie 2, SDR receiver, casing, power supply and off you go. So I officially crossed into the Raspberry Pi now.

It is unclear if it is Legal in Belgium to have one, so I asked BIPT if I could, but still waiting for reply. In the Netherlands it is legal but I found no Belgium sources. For 2 days have been trying every possible Google search but nothing turns up, they all point to the Dutch sources.

I did not yet activate it, waiting for legal feed back first. If it is a NO-GO then I recycle the Raspberry Pi for future projects.

Too many interests, too little time like the new Movidius Neural Compute Stick that accelerates AI computing.

  Are you sure? yes | no

Sepio wrote 08/15/2017 at 15:18 point

You could also move to the Netherlands

  Are you sure? yes | no

Olaf Baeyens wrote 07/25/2017 at 21:05 point

Also learning Inkscape how to develop my buttons for the Nextion HMI  display. Drawing the button is easy but I need to create a bitmap button for every control in an off and on state. So very labor extensive.

On top of that I want to create controls that do not look like rectangular buttons. I want to make it an intuitive look but I think that I first must draw the complete screen with ann buttons on active. Then do it again for all buttons in disabled. Cut both screens in the size of the buttons (twice) and assign them to every pressable Nextion HMI button.

The button images are still rectangular but if the alignment stays correct during cutting out then it should look impressive. Not hard to do but very labor extensive.

The first draft will be a screen intended for the engineer. The top will have every single motor enable/disable and then buttons that can execute a rotate command for every single motor. 7 motors x 5 buttons each and then twice for on/off.

Later stage will be more intuitive but I have to think about the concepts how to do that.

The Nextion HMI does not have normal touche like you are used to have in smart phones. So no swipes. But the buttons can react on button press and button up. This can be used to stop the motor when you release it.  There is also a button that has a double state. This one is for enable/disable and power on/off.

More to come later.

  Are you sure? yes | no

dannyvandenheuvel wrote 07/25/2017 at 21:29 point

In nextion software you don't have to make different bitmaps for buttons etc... You just have to make two identical screen with one all off states and one all on states. then you can draw a rectangle and crop the image. when you switch it's going to hide the upper selected rectangle area so you see the picture beneat it. It's a powerful thing inside the nextion software! Look at the documentation for more info.

You also can do it with sliders as well.

  Are you sure? yes | no

Olaf Baeyens wrote 07/29/2017 at 19:59 point

Hello Danny. Thank for the tip. I tried before but I kept on having compiler errors. That was why I was taking the separate buttons solutions.

But your tip made me aware that there was another way so I retried step by step until I got it working. And now I did.

  Are you sure? yes | no

Olaf Baeyens wrote 07/25/2017 at 20:51 point

Sidetracked for proceeding on the Thor project. My Windows phone was end of life and had to go to Android. Now exploring the wonderful world of NFC. Wondering how to include these reprogrammable NFC tags. with my future projects.  

  Are you sure? yes | no

Olaf Baeyens wrote 07/08/2017 at 18:00 point

Unexpected and hectic week preventing me to work on the Thor robot.

But I did learn to create my own buttons images on Inkscape that will be used in the Nextion HMI. 

I also had to wait until I had my Buck step down converter arrived to convert 24V to 5V. The Ultratronics board is unable to provide enough amperage for the Nextion display.  It finally arrived and is already into place.

I already had 5V from my power supply but I discovered that the power supply has too much energy stored. The motors keep on operating for a few more seconds when I cut the power. So I had a switch on the 24V part but it turns out that somehow the mother board kept on getting power via the 5V.

This step down converter makes the power switch act instantly now. I don't want to lose my fingers when I test alpha software.

  Are you sure? yes | no

Olaf Baeyens wrote 07/01/2017 at 00:36 point

Big milestone, I can make my Nextion HMI touch panel work with the Ultratronics v1.0 pro board which is a Arduino Due.

Enough information for the Arduino mega/Uno/Nano but for the Due it is hard to find.

1. Download and install the ITEADLIB_Arduino_Nextion library.

2. Find NexUpload.cpp and comment out the line that wants to "#include SoftwareSerial.h".  The Arduino Due does not have a SoftwareSerial library only the Arduino Mega/Uno... This is why the compiler fails.

3. The 4 pin header of the Ultratronics v1.0 pro motherboard has a Serial1 and a Serial2. Examples I found for the Nextion are either SoftwareSerial or for Serial (basically Serial0). So go to NexConfig.h and change the line 37 "#define nexSerial Serial1" or #define nexSerial Serial2"

Also don't forget the 5V-3.3V level shifter, The display operates on 5V your Due only 3.3V.

Also the Ultratronics v1.0 pro board cannot deliver enough amperage for the 7 inch display. You need a separate 5V source.

  Are you sure? yes | no

Olaf Baeyens wrote 06/24/2017 at 23:00 point

Test driving the Nextion 7 inch touch panel HMI display on the Ultratronics v1.0 pro motherboard. The motherboard does have 5V and 3.3 V outlets but the 5V clearly does not have enough power to drive the Nextion display. The specification of the display requires 5V 2A power supply. Luckily my main power supply can has a 24V and a 5 V outlet that can drive it as an external power source.

  Are you sure? yes | no

Olaf Baeyens wrote 06/24/2017 at 00:37 point

The Nextion 7 inch touch panel HMI display has arrived. The display is very nice and bright but it does not like my fingers on the touch panel. I initially though it was broken but it works nice with a stylus tip or when I use my nail.

I do not fine a swipe possibility or the ability to use 2 fingers to zoom in or out.

This is not a live streaming display.

  Are you sure? yes | no

Olaf Baeyens wrote 06/18/2017 at 20:47 point

I purchased a Nextion 7 Inch NX8048T070 (https://www.itead.cc/nextion-nx8048t070.html) for a touch screen to control the robot.  (Thanks for the idea Danny)

This panel is probably too big for the Thor robot need, but it can be recycled for future projects.

It is expensive for a panel, but when you realize that it his basically its own computer and can work completely stand alone, then it frees up processor time.


  Are you sure? yes | no

Olaf Baeyens wrote 06/18/2017 at 20:35 point

I finally added my 30x30 mm 24V ventilator in the base.  I initially wanted to add 2 ventilators because the 40x40 mm was too high, but the smaller one seems to suffice. I still need to do longer duration tests. The test so far was only 10 minutes.  

  Are you sure? yes | no

Olaf Baeyens wrote 06/11/2017 at 15:17 point

One of the ideas I have is to add 2 40x40 ventilators in the base. That will force the air in the base upwards, and cools the base motor and the 3 upper motors. The problem is that a 40x40 is too high so I may use the 30x30. 

  Are you sure? yes | no

Olaf Baeyens wrote 06/11/2017 at 15:11 point

The small 3x3 and 4x4 24V ventilators turns out to have connectors where the + and - wires are switched.  So I had to put another connector on it to make to work on the Ultratronics v1.0 pro board.  I am still trying to figure out where to put them. The original idea was to put them inside the plastic but there is not a lot of room inside the Thor robot. 

  Are you sure? yes | no

Olaf Baeyens wrote 06/09/2017 at 19:41 point

Lots of traffic today so I had a couple of hours to think about the next stages in developing the robot. 

Two questions I have been wondering on:

* How do I accurate map my stepper motor steps to the real measured position.

* How do I measure acceleration of a payload and convert that into the desired stepper motor pulses.

I can of course use some hardware as feedback but that will only add more electronics, draws more power and increases the complexity of the programming. I want to have a different way.

A gyroscope and accelerometer is a useful tool. It is cheap, you can put in anywhere, but how do I map the measured accelerations and angles and map this to the stepper motor I used to control the motion?  How do I time-sync both captured date?

I think the solution may be very simple. I let the robot wait and then initially make it move in a jerk move. That impulse will be noticed at both the stepper motor capturing data and the motion recording data capturing logs.  Even if there is a lag between both capturing devices we exactly know the exact moment the data must be synced at.

  Are you sure? yes | no