Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:10 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Electronics : Picaxe Quirk

Author Message
GWatPE

Senior Member

Joined: 01/09/2006
Location: Australia
Posts: 2127
Posted: 12:39pm 14 May 2009
Copy link to clipboard 
Print this post

I have found a problem with the simulator and picaxe run time operation. I have an application that uses an input/output pin for a dual input/output function. The pin is normally an input to check for operation of an external direct control signal to a SSRelay. Under certain conditions the input is changed to an output to directly override the SSRelay operation under program control. The micro handles this operation without problems, but the simulator gets stuck with the condition of the last program control setting. In my case the last control is only a low control. No matter what I do, the simulator gets stuck with this control.

This problem severely disrupts simulation program flow. I am only testing for a high, or a low. The input is indicated as a high, with the yellow bar, but the simulator still reads this as a low input. The picaxe programmer was upgraded to the current version.

Have any other readers experienced this problem? The program logic is sound, and the picaxe chip follows the logic, but the simulator loses the plot.

It is possible that previous programs that I had simulated, that produced unexpected results, could have been purely simulator related.

At least the chip follows the logic.

Gordon.Edited by GWatPE 2009-05-15
become more energy aware
 
GWatPE

Senior Member

Joined: 01/09/2006
Location: Australia
Posts: 2127
Posted: 12:06am 15 May 2009
Copy link to clipboard 
Print this post

I have followed up this error and it does not matter what the value of the analogue input settings are either. This type of problem makes the simulator only suitable for std sequential type logic.

I will recheck with the AXE28X2 simulator, as this is my new toy. I am planning more complicated apps, and I hope the simulator is up to it.

It would be interesting to hear if others have had similar experience.

Gordon.


become more energy aware
 
GWatPE

Senior Member

Joined: 01/09/2006
Location: Australia
Posts: 2127
Posted: 05:46am 18 May 2009
Copy link to clipboard 
Print this post

The simulator develops the problem, as the complexity of the program increases.Edited by GWatPE 2009-05-19
become more energy aware
 
SparWeb

Senior Member

Joined: 17/04/2008
Location: Canada
Posts: 196
Posted: 06:08pm 19 May 2009
Copy link to clipboard 
Print this post

Could you post the code, please? ... and do you mean you will "also" try the 28X simulator, hinting that what you're using at the moment is a different chip?

I've been dabbling in Picaxe lately, so some of these nuances are fresh on my mind.
Have you posted a question on the Picaxe forum? Hippy might straighten you out...

Yesterday the clock on my datalogger started to act up. Pumping out gobbledygook, then suddenly reverting to the correct time. Somehow I was able to listen to my intuition, and replaced the AA batteries. Fixed. Usually I ignore my intuition until days of trying just about everything else turn up empty.
Steven T. Fahey
 
GWatPE

Senior Member

Joined: 01/09/2006
Location: Australia
Posts: 2127
Posted: 01:54am 20 May 2009
Copy link to clipboard 
Print this post

Hi sparweb,

the problem still exists with v5.2.5 simulator.

My problamatic code is subject to commercial copyright. I will try and provide 2 code examples, with very minimal differences, that highlights the problems.

There appears to be an issue with the pins register. The register does not update with the indicated button input following a transition of the pin from an output to an input.

I have a work around that allows me to still use the simulator, by manually pulsing the pin3 input button on the simulator. This seems to update the status of the pins register.

My application now has a memory function that retains user settings following a cct power down. This will allow me to program different functionality into the chip, that is selected and then retained during operation. The program could be altered without the need for a PC, for in field changes. At present I am looking at only 2 options.

These will be good tools for the AXE28X2.

I am looking at a 1wire LCD output as well.

Gordon.

become more energy aware
 
GWatPE

Senior Member

Joined: 01/09/2006
Location: Australia
Posts: 2127
Posted: 08:54am 20 May 2009
Copy link to clipboard 
Print this post

Hi sparweb,

I have some code. This is cut from my main program.

This code works.

  Quote  symbol option1=b0

if pin4=1 then startup

program_options:
if pin2=0 then
option1=2
else
option1=5
endif

startup:
low 0
low 1
low 2
pause 1000
high 0
pause 1000
if pin4=0 then startup

resetstartup:
input 2
high 0

if pin4=0 then startup
if pin2=1 then program_options
goto resetstartup

end



while this code does not


  Quote  symbol option1=b10

if pin4=1 then startup

program_options:
if pin2=0 then
option1=2
else
option1=5
endif

startup:
low 0
low 1
low 2
pause 1000
high 0
pause 1000
if pin4=0 then startup

resetstartup:
input 2
high 0

main:
low 0
pause 20
if pin4=0 then startup
if pin2=1 then resetdelay
low 1
high 0
pause 10
goto main

resetdelay:
low 1
low 2
low 0
pause 50
high 0
pause 450
if pin4=0 then startup
if pin3=0 then resetstartup
goto program_options

end



As I have said above, this code is only a part of my main program.

If the simulator is run with each program, the longer program produces unexpected results. Even though the input2 is clearly yellow[high], a test gives the unexpected branch, for a [low].

The first program follows expected behaviour.

Gordon.

BTW the full program would be too complicated to follow, with memory elements and long counter loops, with many inter related timing loops.

Edited by GWatPE 2009-05-21
become more energy aware
 
Janne
Senior Member

Joined: 20/06/2008
Location: Finland
Posts: 121
Posted: 07:53pm 05 Jul 2009
Copy link to clipboard 
Print this post

I just tested the longer code below. I assume, that this is intended for 08M? At least it's the only mode that the syntax checks out.. anyways, on my 5.2.3 the code runs just like it should on the simulator.
If at first you don't succeed, try again.

My projects
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 07:53am 12 Nov 2009
Copy link to clipboard 
Print this post

Gordon,

You are more than likely well past this now considering the date.

As you would know there is a lot that microchip fails to tell with the picaxe operations at times.

I dont know if this will help as you quote the chip functions as programmed so this might be of little importance.

I found when changing of I.O pins you should introduce a 10ms delay afterwards to allow things to settle.
As you know each instruction takes about 2ms so at times we can have a big enough delay in the program by lines of instructions before calling the changed pin again.

I had the opersite recently where simulator would work fine but errors with the chip.

It was with resetting variables in my case.

I was resetting 2 variables then doing a serin comand to the 2 variables and kept getting invalid data.

By introducing a 10ms delay (20ms for me as running at 8meg) before the serin command produced 100% valid data.


************************************************
Example of code.

setfreq m8

START:

code = 0 ...........'reset b1 to 0
dutycycle = 0 ......'reset b2 to 0

pause 20 .......'Needed this delay to settle variables.

serin RX ,T1200,code,dutycycle,check,battery,setting

pause 10

inc period

***********************************************

If i get a glitch in section of program i add a 20ms delay and if it fixes the glitch then cut it back to 10ms and see if it still works then try 5ms.
But 10ms would appear to be safe most times.

Pete.

Ps. It didnt matter if it ran at 8 or 4 meg the problem was the same.
Edited by Downwind 2009-11-13
Sometimes it just works
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024