1490compass/ picaxe 28x1

sub-bg

New Member
I have been trying output 8 directions from the compass with 8 LEDs
The problem that keeps occurring is that the LEDs on output pins 0,1 and 2
are constantly flashing!the other 5 are just fine though!!

Here is my program :

----------------------------------------------------------------------
dirsc =%00001111 'should declare all port c as inputs

SYMBOL NORTH = pin7
SYMBOL EAST = pin6
SYMBOL SOUTH = pin5
SYMBOL WEST = pin4


main:

low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
if North=0 and South=1 and East=1 and West=1 then label_11
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
if North=0 and South=1 and East=0 and West=1 then label_12
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
if North=1 and South=1 and East=0 and West=1 then label_13
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
if North=1 and South=0 and East=0 and West=1 then label_14
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
if North=1 and South=0 and East=1 and West=1 then label_15
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
if North=1 and South=0 and East=1 and West=0 then label_16
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
'pause 2000
if North=1 and South=1 and East=1 and West=0 then label_17
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
'pause 2000
if North=0 and South=1 and East=1 and West=0 then label_18
low 7
low 6
low 5
low 4
low 3
low 2
low 1
low 0
'pause 2000


goto main ; *****

label_11: high 7
goto main

label_12: high 6
goto main

label_13: high 5
goto main

label_14: high 4
goto main

label_15: high 3
goto main

label_16: high 2
goto main

label_17: high 1
goto main

label_18: high 0
goto main

-------------------------------------------------------------------------
So there is the program and i'd appreciate any feedback
Many Thanks
 

SilentScreamer

Senior Member
I dont know if this will fix it but remove all you "low" statements and change your all the labels between "label_11" and "label_18".

For example:

Code:
label_11:
let pins = %10000000
goto main
 

alband

Senior Member
In the symbol assigning bit at the begginning, you need to put:

Code:
SYMBOL NORTH	= portc pin7
SYMBOL EAST	 = portc pin6
SYMBOL SOUTH	= portc pin5
SYMBOL WEST	 = portc pin4
Also, make sure all the input are tied to ground. SS's suggestion should also vastly improve your codes speed and size.

Edit, in future can you also use the "[/EDOC]" (spelt backwards) indicators to enclose sections of code. It is the little hash (#) symbol in the top right.;)
 
Last edited:

alband

Senior Member
Oh yeah, hmmm.
If you haven't got those resistors I'd try those.
I think you just need to look for differences between pins 0-2 and the rest. All the inputs on the 28X1 are schmitt triggers so no difference there.

Aha, I have an idea.

In you code to reach label_18 (i.e. out0) the code has to flow through al the other checks during which out0 has been put low. Therefore, out0 is only on for a fraction of the time. This means that with the last few checks, the LED will appear to flash instead of stay on.

So, essentially SS has hit the nail on the head and I have rather stepped on his point (sorry there :eek:).
Try it in your simulator with SS's suggestions and check out the difference.
 

Peter M

Senior Member
you could write the main bit like this

Code:
main:
 
 if North=0 and South=1 and East=1 and West=1 then
  pinsc=%10000000
 elseif North=0 and South=1 and East=0 and West=1 then
  pinsc=%01000000
 elseif North=1 and South=1 and East=0 and West=1 then
  pinsc=%00100000
 elseif North=1 and South=0 and East=0 and West=1 then
  pinsc=%00010000
 elseif North=1 and South=0 and East=1 and West=1 then
  pinsc=%00001000
 elseif North=1 and South=0 and East=1 and West=0 then
  pinsc=%00000100
 elseif North=1 and South=1 and East=1 and West=0 then
  pinsc=%00000010
 elseif North=0 and South=1 and East=1 and West=0 then
  pinsc=%00000001
 endif
goto main
then only the true statment is acted upon.

It's also a lot smaller - not that space is realy an issue here?

Grrr...... I hate that program editor locks up my PC when i"m on the net............ try no. 2:mad:

.
 
Last edited:

westaust55

Moderator
Another option is to think about using more maths to create the number to turn on the LED's. You may then not require any subroutines at all. Just manipulate some numbers and one pins = .... statement

Have a look at this thread where I have used a CMPS03 compass module and drive 16 LED's in 32 steps to provide a visual pointer.

http://www.picaxeforum.co.uk/showthread.php?t=9904

Diagrams photos and programe code included in the thread.
See if you can understand the maths involved and adapt to your 8 LED display.
 

slimplynth

Senior Member
my crystal ball is no where near as good as some people's but i'm going to hazard a guess at a Dinsmore 1490. (see first post's title)

I wish I was psychic.. alas the copy of 'dummies guide...' i bought... pg. 312( it was the only electronics book I could find in blackpool last week... a full week without broadband, can you imagine the pain? :()
 
Last edited:

westaust55

Moderator
Edit, in future can you also use the "[/EDOC]" (spelt backwards) indicators to enclose sections of code. It is the little hash (#) symbol in the top right.;)
to type in some text such as [code and [/code]
you can use the [no parse] and [/no parse] command (without spaces)


The 1490 compass module has 4 open collector outputs as per the attached info.

The circuit will need pull up resistors from +5V to the PICAXE input to pull the input signals high when the output is "off". Otherwise the inputs will float and may give seemingly erroneous directions.
 

Attachments

Last edited:
Top