picaxe 28X2 download help

LED Maestro

Senior Member
Hello,
I have been trying to download my code onto a 28X2 but every time I test, after download, to make sure it works, all it does is make an LED flicker. I have tried it with very simple code like
Code:
Main:
If pinc.1 = 1 then
high b.7
endif
goto main
But it does the same thing, it makes the LED on o/p b.7 flicker regardless of whether pinc.1 is high or low.
Any help would be uber appreciated as I am loosing hope
Many thanks
 
Last edited:

BeanieBots

Moderator
It's a little confusing what you are asking.
The title suggests a problem getting your program in the PICAXE.
Your code will turn the LED on and leave it on until the PICAXE is switched off. Is that what you want?

Make sure the reset line is pulled high.
Make sure the download circuit is correct.
Make sure you have a pull-down resistor on your input pin.

Does this work? (the LED should flash)
Code:
Do
  Toggle B.7
  Pause 500
Loop
 

LED Maestro

Senior Member
Thanks for the reply beanie,
The code does work of sorts. It flashes 4 times then flashes 4 times in quick sucession. My download circuit is correct as it downloads my code. srnet, a momentary push button switch is connected to pinc.1. My understanding is that if power goes to pinc.1 then high b.7. but I could be wrong. I haven't been programming for long. my code is in the next post.

Please, no comments on the length or I could hae done something better. It suits my needs and works on the sim so that's fine by me. Like I said in my first post, my first output just flickers regardles of whether a.1 is high or low.
Hope I am making a bit more sense.
Many thanks
 

LED Maestro

Senior Member
Code:
setint %00000001,%00000001

led1on:
 do if pina.1 = 1 then
high c.7 goto led2on
else loop endif

led2on: pause 500
 do if pina.1 = 1 then
high c.6 goto led3on
endif
if pina.0 = 1 then
low c.7 goto led1on
else loop endif

led3on: pause 500
 do if pina.1 = 1 then
high c.5 goto led4on
endif
if pina.0 = 1 then
low c.6 goto led2on
else loop endif

led4on: pause 500
 do if pina.1 = 1 then
high c.4 goto led5on
endif
if pina.0 = 1 then
low c.5 goto led3on
else loop endif

led5on: pause 500
 do if pina.1 = 1 then
high c.3 goto led6on
endif
if pina.0 = 1 then
low c.4 goto led4on
else loop endif

led6on: pause 500
 do if pina.1 = 1 then
high c.2 goto led7on
endif
if pina.0 = 1 then
low c.3 goto led5on
else loop endif

led7on: pause 500
 do if pina.1 = 1 then
high c.1 goto led8on
endif
if pina.0 = 1 then
low c.2 goto led6on
else loop endif

led8on: pause 500
 do if pina.1 = 1 then
high a.3 goto led9on
endif
if pina.0 = 1 then
low c.1 goto led7on
else loop endif

led9on: pause 500
 do if pina.1 = 1 then
high b.7 goto led10on
endif
if pina.0 = 1 then
low a.3 goto led8on
else loop endif

led10on: pause 500
 do if pina.1 = 1 then
high b.6 goto led11on
endif
if pina.0 = 1 then
low b.7 goto led9on
else loop endif

led11on: pause 500
 do if pina.1 = 1 then
high b.5 goto led12on
endif
if pina.0 = 1 then
low b.6 goto led10on
else loop endif

led12on: pause 500
 do if pina.1 = 1 then
high b.4 goto led13on
endif
if pina.0 = 1 then
low b.5 goto led11on
else loop endif

led13on: pause 500
 do if pina.1 = 1 then
high b.3 goto led14on
endif
if pina.0 = 1 then
low b.4 goto led12on
else loop endif

led14on: pause 500
 do if pina.1 = 1 then
high b.2 goto led15on
endif
if pina.0 = 1 then
low b.3 goto led13on
else loop endif

led15on: pause 500
 do if pina.1 = 1 then
high b.1 goto led16on
endif
if pina.0 = 1 then
low b.2 goto led14on
else loop endif

led16on: pause 500
 do if pina.1 = 1 then
high b.0 goto led16off
endif
if pina.0 = 1 then
low b.1 goto led15on
else loop endif

led16off: pause 500
 do if pina.0 = 1 then
low b.0 goto led16on
endif
if pina.1 = 1 then
goto overload
else loop endif

overload: pause 500
low c.7, c.6, c.5, c.4, c.3, c.2, c.1, a.3 
low b.7, b.6, b.5, b.4, b.3, b.2, b.1, b.0

overload1:
high c.4, c.3 pause 300
if pina.0 = 1 then goto overloadoff
low c.4, c.3
if pina.0 = 1 then goto overloadoff
high c.5, c.2 pause 300
if pina.0 = 1 then goto overloadoff
low c.5, c.2 
if pina.0 = 1 then goto overloadoff
high c.6, c.1 pause 300
if pina.0 = 1 then goto overloadoff
low c.6, c.1 
if pina.0 = 1 then goto overloadoff
high c.7, a.3 pause 300
if pina.0 = 1 then goto overloadoff
low c.7, a.3 
if pina.0 = 1 then goto overloadoff
high b.7, b.0 pause 250
if pina.0 = 1 then goto overloadoff
low b.7, b.0 
if pina.0 = 1 then goto overloadoff
high b.6, b.1 pause 250
if pina.0 = 1 then goto overloadoff
low b.6, b.1 
if pina.0 = 1 then goto overloadoff
high b.5, b.2 pause 250
if pina.0 = 1 then goto overloadoff
low b.5, b.2 
if pina.0 = 1 then goto overloadoff
high b.4, b.3 pause 250
if pina.0 = 1 then goto overloadoff
low b.4, b.3
if pina.0 = 1 then goto overloadoff

high c.4, c.3 pause 200
if pina.0 = 1 then goto overloadoff
low c.4, c.3
if pina.0 = 1 then goto overloadoff
high c.5, c.2 pause 200
if pina.0 = 1 then goto overloadoff
low c.5, c.2 
if pina.0 = 1 then goto overloadoff
high c.6, c.1 pause 200
if pina.0 = 1 then goto overloadoff
low c.6, c.1 
if pina.0 = 1 then goto overloadoff
high c.7, a.3 pause 200
if pina.0 = 1 then goto overloadoff
low c.7, a.3 
if pina.0 = 1 then goto overloadoff
high b.7, b.0 pause 150
if pina.0 = 1 then goto overloadoff
low b.7, b.0 
if pina.0 = 1 then goto overloadoff
high b.6, b.1 pause 150
if pina.0 = 1 then goto overloadoff
low b.6, b.1 
if pina.0 = 1 then goto overloadoff
high b.5, b.2 pause 150
if pina.0 = 1 then overloadoff
low b.5, b.2 
if pina.0 = 1 then goto overloadoff
high b.4, b.3 pause 150
if pina.0 = 1 then goto overloadoff
low b.4, b.3
if pina.0 = 1 then goto overloadoff

high c.4, c.3 pause 150
if pina.0 = 1 then goto overloadoff
low c.4, c.3
if pina.0 = 1 then goto overloadoff
high c.5, c.2 pause 150
if pina.0 = 1 then goto overloadoff
low c.5, c.2 
if pina.0 = 1 then goto overloadoff
high c.6, c.1 pause 150
if pina.0 = 1 then goto overloadoff
low c.6, c.1 
if pina.0 = 1 then goto overloadoff
high c.7, a.3 pause 150
if pina.0 = 1 then goto overloadoff
low c.7, a.3 
if pina.0 = 1 then goto overloadoff
high b.7, b.0 pause 100
if pina.0 = 1 then goto overloadoff
low b.7, b.0 
if pina.0 = 1 then goto overloadoff
high b.6, b.1 pause 100
if pina.0 = 1 then goto overloadoff
low b.6, b.1 
if pina.0 = 1 then goto overloadoff
high b.5, b.2 pause 100
if pina.0 = 1 then goto overloadoff
low b.5, b.2 
if pina.0 = 1 then goto overloadoff
high b.4, b.3 pause 100
if pina.0 = 1 then goto overloadoff
low b.4, b.3
if pina.0 = 1 then goto overloadoff

high c.4, c.3 pause 100
if pina.0 = 1 then goto overloadoff
low c.4, c.3
if pina.0 = 1 then goto overloadoff
high c.5, c.2 pause 100
if pina.0 = 1 then goto overloadoff
low c.5, c.2 
if pina.0 = 1 then goto overloadoff
high c.6, c.1 pause 100
if pina.0 = 1 then goto overloadoff
low c.6, c.1 
if pina.0 = 1 then goto overloadoff
high c.7, a.3 pause 100
if pina.0 = 1 then goto overloadoff
low c.7, a.3 
if pina.0 = 1 then goto overloadoff
high b.7, b.0 pause 50
if pina.0 = 1 then goto overloadoff
low b.7, b.0 
if pina.0 = 1 then goto overloadoff
high b.6, b.1 pause 50
if pina.0 = 1 then goto overloadoff
low b.6, b.1 
if pina.0 = 1 then goto overloadoff
high b.5, b.2 pause 50
if pina.0 = 1 then goto overloadoff
low b.5, b.2 
if pina.0 = 1 then goto overloadoff
high b.4, b.3 pause 50
if pina.0 = 1 then goto overloadoff
low b.4, b.3
if pina.0 = 1 then goto overloadoff

high c.4, c.3 pause 50
if pina.0 = 1 then goto overloadoff
low c.4, c.3
if pina.0 = 1 then goto overloadoff
high c.5, c.2 pause 50
if pina.0 = 1 then goto overloadoff
low c.5, c.2 
if pina.0 = 1 then goto overloadoff
high c.6, c.1 pause 50
if pina.0 = 1 then goto overloadoff
low c.6, c.1 
if pina.0 = 1 then goto overloadoff
high c.7, a.3 pause 50
if pina.0 = 1 then goto overloadoff
low c.7, a.3 
if pina.0 = 1 then goto overloadoff
high b.7, b.0 pause 10
if pina.0 = 1 then goto overloadoff
low b.7, b.0 
if pina.0 = 1 then goto overloadoff
high b.6, b.1 pause 10
if pina.0 = 1 then goto overloadoff
low b.6, b.1 
if pina.0 = 1 then goto overloadoff
high b.5, b.2 pause 10
if pina.0 = 1 then goto overloadoff
low b.5, b.2 
if pina.0 = 1 then goto overloadoff
high b.4, b.3 pause 10
if pina.0 = 1 then goto overloadoff
low b.4, b.3
if pina.0 = 1 then goto overloadoff

high c.4, c.3 pause 10
if pina.0 = 1 then goto overloadoff
low c.4, c.3
if pina.0 = 1 then goto overloadoff
high c.5, c.2 pause 10
if pina.0 = 1 then goto overloadoff
low c.5, c.2 
if pina.0 = 1 then goto overloadoff
high c.6, c.1 pause 10
if pina.0 = 1 then goto overloadoff
low c.6, c.1 
if pina.0 = 1 then goto overloadoff
high c.7, a.3 pause 10
if pina.0 = 1 then goto overloadoff
low c.7, a.3 
if pina.0 = 1 then goto overloadoff
high b.7, b.0 pause 10
if pina.0 = 1 then goto overloadoff
low b.7, b.0 
if pina.0 = 1 then goto overloadoff
high b.6, b.1 pause 10
if pina.0 = 1 then goto overloadoff
low b.6, b.1 
if pina.0 = 1 then goto overloadoff
high b.5, b.2 pause 10
if pina.0 = 1 then goto overloadoff
low b.5, b.2 
if pina.0 = 1 then goto overloadoff
high b.4, b.3 pause 10
if pina.0 = 1 then goto overloadoff
low b.4, b.3
if pina.0 = 1 then goto overloadoff

high c.4, c.3  
if pina.0 = 1 then goto overloadoff
low c.4, c.3
if pina.0 = 1 then goto overloadoff
high c.5, c.2  
if pina.0 = 1 then goto overloadoff
low c.5, c.2 
if pina.0 = 1 then goto overloadoff
high c.6, c.1  
if pina.0 = 1 then goto overloadoff
low c.6, c.1 
if pina.0 = 1 then goto overloadoff
high c.7, a.3  
if pina.0 = 1 then goto overloadoff
low c.7, a.3 
if pina.0 = 1 then goto overloadoff
high b.7, b.0  
if pina.0 = 1 then goto overloadoff
low b.7, b.0 
if pina.0 = 1 then goto overloadoff
high b.6, b.1  
if pina.0 = 1 then goto overloadoff
low b.6, b.1 
if pina.0 = 1 then goto overloadoff
high b.5, b.2  
if pina.0 = 1 then goto overloadoff
low b.5, b.2 
if pina.0 = 1 then goto overloadoff
high b.4, b.3  
if pina.0 = 1 then goto overloadoff
low b.4, b.3
if pina.0 = 1 then goto overloadoff

overloadoff: pause 500
low c.7, c.6, c.5, c.4, c.3, c.2, c.1, a.3 
low b.7, b.6, b.5, b.4, b.3, b.2, b.1, b.0
high c.7, c.6, c.5, c.4, c.3, c.2, c.1, a.3 
high b.7, b.6, b.5, b.4, b.3, b.2, b.1, b.0
goto led16off

interrupt:
high a.2
if pinc.0 = 1 then interrupt
setint %00000001,%00000001
low a.2
return
 

hippy

Technical Support
Staff member
Code:
led1on:
 do if pina.1 = 1 then
high c.7 goto led2on
else loop endif

led2on: pause 500
I'm surprised that even got through syntax checking !

It might be worth taking a step back as you are new to the game and getting simpler programs working with real hardware first. Also, getting that experience should help you to write more optimised and clearer code. For example, what you have could instead be written as -

Code:
led1on:
  Do : Loop Until pina.1 = 1 
  High c.7

led2on:
  Pause 500
That will be much clearer for others to follow and for yourself to debug.
 

Goeytex

Senior Member
Please, no comments on the length or I could hae done something better. It suits my needs and works on the sim so that's fine by me.
Forgive me for chuckling .... but that may not be an option. You want help? Then let folks help.
IMO not to many folks are gonna want to sort through that code.

At least clearly say what you want the code to do. And then clearly say what it actually does or does not do.

And please post a schematic
 

LED Maestro

Senior Member
Hey goeytex. You are forgiven for chuckling. I can't explain very well what I want my circuit to do. That's why I have put a link to a vid on youtube.
http://www.youtube.com/watch?v=BLYiVdC7Iv4
Unfortunately I haven't had time to do a schematic. I will get one on here soon I hope.
Jamster, the reset is tied high with a 4k7 resistor.
M47, I was not aware I needed a resistor on the input pin. Could you explain, if you don't mind, why it is needed and would a 1k or 10k be OK?
Thanks hippy for the code. I will give that a go and see what I come up with. I know I must have sounded a bit stubborn with my request for no comments on the code and for that I appologise. I was a bit annoyed at the time.
Thanks again
 

BeanieBots

Moderator
My download circuit is correct as it downloads my code.
Not true. Leave out the 10k resistor and it will download fine.
Run the program without the download cable and it could easily behave as you describe.

Did the code I posted work?
If it did not give a good regular flash, then it may be your download circuit and/or reset connection.
The pull-down resistor (10k is fine) on your input is required to prevent the input floating which again can lead to erratic behaviour.
 

srnet

Senior Member
Unfortunately I haven't had time to do a schematic. I will get one on here soon I hope.
Well you should make time, pencil paper camera, what, 5 minutes work ?

Its so helpful to all those that are giving you free advice, and saves thier time
 

LED Maestro

Senior Member
Srnet, being at college I do not have a lot of free time. Regardless of whether or not it takes 5 minutes, I am studying quite hard for upcoming exams. However I have just tested my picaxe again and it turns out I had a dodgy power rail on by breadboard. MartinM57 and beaniebots, I thank you for the advice about the resistors. I think that was another cause as to why my circuit was behaving oddly. I have now tied all inputs to ground with 10k resistors.
Thanks to all again and my apologies for wasting anybody's time.
 

nick12ab

Senior Member
However I have just tested my picaxe again and it turns out I had a dodgy power rail on by breadboard.
Are you sure that's the case or do you have one of those breadboards where the power rails are not joined in the middle so require small jumper links to be inserted?

 
Top