compiler simulation help

bobbyblank

New Member
Hey. im trying to come up with a way to randomly turn an output pin on a
08M. I made some code using a snippet or to off these forums and ran it through the simulation in the picaxe compiler. Worked fine. Probably a better way to do it, but that isnt my issue right now. as soon as i place the axe into a circuit with 4 LEDs to test it, all i get is output pin0 blinking. Here is the circuit. its just to test to see if the pins were going high and low because i dont have a logic probe.
 

Attachments

Last edited:

Artie2

New Member
The first thing I can think of is that the Picaxe powers up with pins 1,2,3, and 4 as inputs. Only pin 0 is an output. You must explicitly declare 1,2, and 4 as outputs.

Edit: Also, your "pause" is only 25 ms's. That might be too short of a pulse to see the light. You might up that to 250 or 500 just to check.

Edit 2: One more thing: Sometimes its easier to just alter one variable, rather than many, when you're trying to find the right "blink-rate". Add this to the beginning of your program:

Code:
symbol on_time = w6
on_time = 500 ' Modify this value to change all the pause times
Then change all your "pauses" to:

Code:
PAUSE on_time
Now you only have to change one number to alter all the pauses.
 
Last edited:

bobbyblank

New Member
The delay was supposed to be 250, its was a typo. changed delay and declared outputs and same results, output 0 with a slow blink. figured i would download a simple toggle 4, pause toggle 4 pause code to see if i could get action on another pin and got nothing, just output 0 blinking. Could my powersupply be a problem and not downloading code correctly? my download circuit is powerd by a wall transformer used for chargeing an old cell phone. Puts out 5.05v. any code i put into this using the simple LED circuit just does nothing. all i get is a slow blink from output 0. Im not familiar with these chips, i used to use a BS2 with no problems. I breadboarded the circuit again and get the same results, breadboard is a Steren powed by and 1.5 - 12v wall trasnformer from radioshack running on a 4.5v setting.
 
Last edited:

Artie2

New Member
Sometimes the voltage regulation on those wall-warts isn't too good. Also, when I run your code, (even with the corrected pause times), I only get output 1 and 2 "on" occasionally, with zero never on.

You might want to try this simple code as a troubleshooting guide. See if this works any better:

Code:
setup:
 dirs=%00010111
main:
 RANDOM b0
 pins=b0
 goto main
Just a thought.

Edit: I just made an interesting discovery: If I remove the "dirs=%00010111" line from my simple code, then only the zero output works also. Maybe you should include that line. (To define outputs.)
 
Last edited:

bobbyblank

New Member
Sometimes the voltage regulation on those wall-warts isn't too good. Also, when I run your code, (even with the corrected pause times), I only get output 1 and 2 "on" occasionally, with zero never on.

You might want to try this simple code as a troubleshooting guide. See if this works any better:

Code:
setup:
 dirs=%00010111
main:
 RANDOM b0
 pins=b0
 goto main
Just a thought.

Edit: I just made an interesting discovery: If I remove the "dirs=%00010111" line from my simple code, then only the zero output works also. Maybe you should include that line. (To define outputs.)


thats odd, when i simulate it, i get all four outputs going. with only one pin at a time. The whole goal in the end is to randomly select an output pin, and them PWM an LED on that pin to slowly fade on and off. thats what im trying for anyway lol. your code runs multiple outputs at the same time, dont know if i can PWM all the high outputs at the same time. Hell, until i can figure out why i can toggle any of my pins to do anything, i can put the codeing aside i guess. i guess ill have to whip up a new download circuit with a 7805 and try that. its odd though because i downloaded a program the other day and ran 2 motors off a L293 with no problems.
 

hippy

Ex-Staff (retired)
Take RANDOM and all other complexity out of the equation for now and try a simpler program to test that the LED's do work on the physical chip ...

Code:
Do
  High 0 : Pause 1000 : Low 0
  High 1 : Pause 1000 : Low 1
  High 2 : Pause 1000 : Low 2
  High 4 : Pause 1000 : Low 4
Loop
If that works then it is something related to the program code.
 

bobbyblank

New Member
Take RANDOM and all other complexity out of the equation for now and try a simpler program to test that the LED's do work on the physical chip ...

Code:
Do
  High 0 : Pause 1000 : Low 0
  High 1 : Pause 1000 : Low 1
  High 2 : Pause 1000 : Low 2
  High 4 : Pause 1000 : Low 4
Loop
If that works then it is something related to the program code.
i tried that already, just toggleing off all the pins and did not work. thats why im thinking a power supply issue maybe?
 

hippy

Ex-Staff (retired)
If pin0 works but others do not it is unlikely to be a power supply problem. Things to check -

Circuit error
LED's not connected
LED's in backwards
Current limiting R's too high
 

Technical

Technical Support
Staff member
Your initial sketch does not show the 10k/22k on the download pin..... they are there aren't they...?
 

bobbyblank

New Member
Your initial sketch does not show the 10k/22k on the download pin..... they are there aren't they...?

No they are not, i have downloaded the code on a small programming board i made. Did not think they were required if you were not doing "in circuit" programming.

As far as the resistors go, just 330 ohms, and i would hope the LEDs are in correctly being such a simple circuit, but i have made worst mistakes on other projects lol. im not at home to check, but i will have to look when i return from work.
 

BeanieBots

Moderator
A pull-down on serin is ESSENTIAL.
Erratic behaviour will occur without because the pin will float and the PICAXE will think a download is about to happen.
You do not need both resistors, just one of any value 1k - 100k will do.
You could even link to 0v but that is not "good pratcice".
 

bobbyblank

New Member
A pull-down on serin is ESSENTIAL.
Erratic behaviour will occur without because the pin will float and the PICAXE will think a download is about to happen.
You do not need both resistors, just one of any value 1k - 100k will do.
You could even link to 0v but that is not "good pratcice".
Ah!, makes much sense. Didnt think it would be an issue if it floats since it was not going to be used as an I/O. I will try it when i get home but im sure it will solve the issues. Thanks for all the help everyone. Ill let you know how it goes later today.
 
Top