how to map x y co-ordinates on a picaxe 28x1

tonto2k

Member
Hi all,

I am building a drink fetching robot using a Airat2 Micromouse Body Set with 2 x Sanyo Denki 103H546-0440 (Nema Frame 17) stepper motors and a JS Motor Board (I got a good deal on ebay! ) I am interfacing it with a 28x1 picaxe.

My plan is to navigate around a 9 x 9 square (20x20 each square) grid using a x/y grid, using wavefront mapping. I have looked at various various articles on the internet about mapping a room but most of them are coded in C which I am not familiar with.

I noticed that you could put an array into the code with C so it was possble to map out the area quite easily. However I cannot find any information on using arrays in Picaxe, is it possible?

I would like to be able to tell my robot to travel from for example x1-y1 to x3-y3, does anyone have any ideas how to do this? Sorry if my description is unclear I am finding it hard to explain ! :)

Thanks in advance,
Tonto.
 

Jeremy Leach

Senior Member
Hi Tonto,
I don't know about the robotics side, but in terms of picaxe basic there aren't any specific array commands or array data structures. However arrays are just data, and the picaxe can index data in either EEPROM or RAM (internal or external).

The key things I can see are:
1. what sort of data do you want to store in your map 'array'? If it's just the outline of objects then each coordinate could be represented by a single bit perhaps.
2. How many unique coordinates do you need to store for the map? This will determine the amount of data storage you need.
3. Is the map a temporary thing, or do you need it to be remembered at power-off? This will determine whether you need to use RAM or EEPROM storage.


Once you've thought about this, it's really just a matter of writing code subroutines to perform the 'array' type actions you are interested in. The core to it all will probably be two routines - one to write data to the array at point x,y and one to read the data. Because data is stored sequentially in RAM or EEPROM, you will need to do some calculations using the x and y coordinates to work out the address of the 'array cell' you are interested in.

As a start I suggest you look at the peek,poke,read,write commands to get a feel for how to store and retrieve information from RAM and EEPROM. (see Manual 2, via the 'datasheets' drop-down at the top of the forum).
 
Last edited:

BeanieBots

Moderator
PICAXE does not support arrays as such but you can get the same result.
Store your data in RAM using the poke command and then use a variable to define the address when getting it back with the peek command. Not sure how would do multidimensioned arrays but doing something crafty with masking bits of the address variable might work.
The 28X1 also has a scratchpad with extra features which might suit your requirements.
 

westaust55

Moderator
lets say you have an array of 9 x 9 (x and y respectively) which gives 81 cells.
Then using 81 consecutive memory locations and a formula to get a pointer is easy.

Cell/location = x + y*MaxX - where, in our 9 x 9 case MaxX = 9

Would need more information to assist with navigation between two points.


IF permitted to travel “as-the-crow-flies” THEN
no walls to worry about could use some algorithms akin to my line drawing routines I wrote for the gLCD display from an Siemens A55 mobile phone display - straight line from point a to point b.
ELSEIF there are walls THEN
each of the 81 cells will contain values representing which sides have walls. Maybe one bit representing each wall, so 1 = north wall, 2 = west wall, 4= south wall and 8 = east wall and OR them if each wall that exists.
ENDIF

Then need some code to calculate the available path between two points.
 

wbryan

New Member
Throwing this question up to ensure you've thought about it: Are you going to represent each cell and the walls on four sides of it, or just the array of walls. If you are representing the cells, then each wall will need to be represented in the cell on either side of the wall. Except at the edges of the array of course. Representing just the walls makes the data structure easier, but isn't so good for the maze solver code.

The IEE Micromouse competition was my final year project at Uni. I'll see if I can find which option I chose. I didn't have the time or money to build hardware, so my project ended up consisting of a C based software solver that interfaced to an simulated mouse and environment. That was 12 years ago now.

If you're just navigating a room, perhaps walls isn't the right representation at all. Perhaps just having the array of cells and considering them to be occupied (blocked) or not. You might consider the a* algorithm for finding the shortest path (http://en.wikipedia.org/wiki/A*_search_algorithm). It ought to be picaxe-able from my experience of it.

Will
 
Last edited:
Top