Notifications
Clear all

Joe's Home Robot

11 Posts
5 Users
3 Likes
360 Views
(@jpgeorgia)
Member
Joined: 10 months ago
Posts: 8
Topic starter  

Hello, forum mates.

I'm beginning construction of an indoor robot. I call it a beginning, but I had started this project over a year ago. I began programming two Arduino 2560 boards. I gradually learned the 2560's programming limitations. I wrote a sketch that became intricate and complicated. One problem is the Arduino's limitation to one-dimensional arrays. I tried to stick to my sketch approach, but it became unwieldy. I came up with a method to simulate two dimensions. That approach brought on complications. I eventually solved them. Then came my own medical problems and two dead computers. MS auto backup is not what it's cracked up to be. All this had complicated my robot construction. Today, I have passed all that and I am once more functional.

My current plan for an indoor robot involves purchasing all the parts I need. I had planned to use 3D printing. I had a complete high-definition printer system but no longer because of odors.

1. Robot body: I purchased a tower computer case. It has a cooling fan, and I have a second fan just in case

2. Battery: I have settled on a 12V lead acid battery, the type used in uninterruptible power supplies (UPS). It is rechargeable and has the current voltage requirements for motors. I can step down the voltage for circuit boards.

3. Wheels. I began with determining motors like the Dronebot Workshop does or did. I discovered (perhaps wrongly) that I must determine wheels before motors and robot weight before wheels. I have settled on a general 20% or more overdesign philosophy. So, I decided on a 50-pound robot and four 5-inch wheels with soft tires to navigate wood and tile floors. For steering, I plan to use PWM on the two front wheels or all four wheels. I found an online Drive Motor Sizing Tool at the RobotShop Community website.

4. I will purchase hardware to increase the robot's base size for stability. Of course, the battery will be inside the case on the bottom.

5. Motors. This is my next step. I'm now searching for motors capable of handling 25-pounds each on a 45-degree grade (my overdesign philosophy). I will determine the motor shaft length and diameter. The motors will be inside the case.

That's where the robot is today. I invite your comments.

Thanks, Joe.


   
rommudoh reacted
Quote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@jpgeorgia wrote:

"One problem is the Arduino's limitation to one-dimensional arrays."

Are you sure? I can compile two dimensional arrays with the Mega board selected.

I once built a medium sized robot that used 24volt windscreen wiper motors. One of the motors failed (oil leak into motor) so it is now scrapped. You can see the two little sealed lead acid batteries I used.

To enlarge an image, right click image and select Open link in new window.

robot Base1

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7008
 

@jpgeorgia Here is a link to a tutorial on multi-dimension arrays. https://www.tutorialspoint.com/arduino/arduino_multi_dimensional_arrays.htm

Make sure your lead acid batteries are of the sealed type, or better still use LiFePO4, much safer, better all round other than up front cost but lifetime cost is less.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@jpgeorgia)
Member
Joined: 10 months ago
Posts: 8
Topic starter  

@robotbuilder Wow, you are correct, and I am quite surprised. I tried a two-dimensional array on the online Arduino Editor, and the sketch compiled in a "check and save". In fact, after declaring int Test [2] [2], I was able to assign values to Test [4] [5], and the compiler accepted it. I guess it redimensioned my array. The only explanation I can come with is that I had used an old downloaded IDE app, but I am not sure. At the time, I did confer with another Arduino hobbyist, and he had the same problem. He had written and used a sketch function to simulate a two-dimensional array. It was too complicated for me to follow, so I designed my own. It was longer than his, but it was easy to follow. Thanks for your help.


   
ReplyQuote
(@jpgeorgia)
Member
Joined: 10 months ago
Posts: 8
Topic starter  

@zander UPS batteries are sealed lead acid batteries. Otherwise, they would leak during shipping. Another reason I chose those batteries is cost.

Thanks for your advice. Joe.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1694
 

Hi @jpgeorgia,

I think multi-dimensional arrays are likely to always have been possible, but I was concerned about your supplementary 'discovery'.

re: after declaring int Test [2] [2],

I was able to assign values to Test [4] [5], and the compiler accepted it.

I assume you are referring to C/C++ .... now I admit I am out of date with compiler changes, so I appeal to others to correct me if there are any 'clever' tricks I am unaware of,

but I would interpret 'compiler accepted it' means 'compiler didn't care or check'

When a compiler allocates memory for an array, it simply figures out how many bytes are required for the original size requested, and saves that amount of space.

When an assignment for a given position in the array, the code figures out a memory address for that array member, based on the start address of the array and the array indices as offsets into that array.

In many cases, the compiler does not check that that address actually falls within the block of memory allocated for the array, and obviously if it is outside, the assignment can still be attempted, but will result in something else being overwritten, possibly even program code, depending upon the memory map.

Of course, protection methods to prevent this happening are possible ... but in many cases they are omitted, at least from the final run time code, because they require extra resources, computations and so on.

But my guess, on an Arduino system, it will either:

  • still work, because the overwrite happened to a bit of spare memory

or

  • break, because the rightful contents of the memory that got overwritten, have been changed

And if you are really unlucky, both of the above can apply, so that it works every time you test it, but fails when someone else tries to use it.

.....

Of course, this is related to one of the common ways of hacking into a system ... feed in some data that is larger than expected, and in the process, overwrite the program with some alternate code of the hacker's choosing.

----

Moral ..

If a compiler refuses some code, you definitely have a problem.

If a compiler accepts some code, you are in with a chance of success, but in most cases, your problems haven't been identified....yet!

Best wishes and happy coding, Dave


   
ReplyQuote
(@jpgeorgia)
Member
Joined: 10 months ago
Posts: 8
Topic starter  

@davee I go along with your notion that the compiler did not check the declaration and the sketch will likely crash during execution.

Joe


   
DaveE reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7008
 

@jpgeorgia FYI @davee Multi-dimensional arrays are a standard part of C and C++ and Arduino.

Here is a tutorial on the subject. https://www.tutorialspoint.com/arduino/arduino_multi_dimensional_arrays.htm

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@hilldweller)
Member
Joined: 1 year ago
Posts: 111
 

Posted by: @jpgeorgia

 In fact, after declaring int Test [2] [2], I was able to assign values to Test [4] [5],

 

You are standing in the middle of a minefield. You can declare [2][2] then store in [4][5] but if you did not declare[4][5] C will happily store there putting data on top of other data. It then goes BANG.

 

To be honest I'm not sure if this is what you mean but the number of times I've shot myself in the foot with arrays is distressing.

 

int x[2];

x[2] = 123;

BANG.

C is very cunning, it waits for the worst possible moment to go BANG as in "Hey look at this, impressive !". Then BANG.

 

 

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7008
 

@hilldweller I forget what it's called, but there is a switch you can turn on to detect out-of-bounds conditions. It will affect performance, but at least it won't go bang.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Brian reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7008
 

@hilldweller There may even be a #pragma that makes the bounds checking overhead only affect those statements that MIGHT go bang.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote