Newbie needing help for project please

thelittlesthobo

New Member
Hello
I am new to picaxe but have some basic knowledge of C. I am trying to make a fault code reader for a product that uses flash codes for its DTCs. So im using a 20M2 to read these flash codes and then display the relevant faults (max 5) on the OLED display.
Firstly how do I declare Integers, variables etc so that I may store values to them to use within te program
and second, I want to measure the length of a 0V period on pin7 using the command 'pulsin' and then use this info in a followinf IF statement which wiil decide on which function to go to???
If I can get the hang of this, I think I may have most of my problems sorted, apart from arrays actually. I want to store up to 5 faults in an array to later print to the OLED display. The faults are numbered 1 - 10 and I planned on putting the messages/fault descriptin in the user defined messages within the OLED AXE133Y Firmware File.
Any help would be greatly appreciated.
Thanks
Robin
 

nick12ab

Senior Member
Firstly how do I declare Integers, variables etc so that I may store values to them to use within te program
Use the symbol command to assign names to any word variable (w0-w13), byte variable (b0-b27), bit variable (bit0-bit31, part of b0-b3) or constant. Byte variables share the same space as word variables (w0 = b1 : b0).

Additional RAM can be accessed by using the bptr and @bptr variables.

and second, I want to measure the length of a 0V period on pin7 using the command 'pulsin' and then use this info in a followinf IF statement which wiil decide on which function to go to???
The question is?

apart from arrays actually
PICAXE is limited with support for arrays, however @bptr and bptr can be used to simulate arrays.
 

westaust55

Moderator
Welcome to the PICAXE forum.

It is not compulsory to "declare" variables but use of the SYMBOL directive to give an alias to variabkes, constants and even IO will certainly make reading/understanding the program code easier.

Positive Integers are the only type of values the PiCAXE can work with. Max values for storing and interal math is 65535.
Where 1 or 2 decimal places are sought the usual practice is to multiply values by 10 or 100.

Alternative program structures to a series of IF..THEN include
SELECT... CASE or ONGOSUB which can be useful when you use some math to evaluate the pulse duration and the result is a value 0,1,2,3....
 

hippy

Ex-Staff (retired)
So im using a 20M2 to read these flash codes and then display the relevant faults (max 5) on the OLED display.
This should be achievable with a PICAXE. Split the project into stages / sub-modules and experience gained in one stage will help you with the next.

I'd suggest starting by just detecting the code, converting that to a number and displaying it using SERTXD or DEBUG.

Alter that to print a different message depending on value. Finally put it to an OLED display.
 
Top