Picaxe Project Ideas for Physics

kam

Member
Thank You

:)Hi all,

Just wanted to thank you all for the support and help. Its a little late i know but i was too busy to come online in a while.

The project is up and running and i have even started datalogging for my first experiment sample.

Thankyou all again for your help and support.

Regards
Kam
:)
 

kam

Member
Hey guys,

I got the pics in and realized that my flash disk has given up. its one of those viruses I've seen before on my friends disks. It basically cleans up a major part of the disk space.

Anyway
Heres the code:

main:

pause 750
readtemp 1,b1
readtemp 0,b2
readtemp 7,b3

if b1 < 127 and b2 < 127 and b3 < 127 then gosub out
if b1 > 127 then gosub negb1 ' check for negitive value
if b2 > 127 then gosub negb2
if b3 > 127 then gosub negb3
let b9 = 0

goto main

out:
if b2 = b1 then gosub buzz
if b9 = 1 then back
sertxd ("Temp1: ",#b1, ", Temp2: ",#b2, ", Temp3: ",#b3, cr,lf)
return

negb1:

let b1 = b1 - 128
sertxd ("Temp1: -",#b1, ", Temp2: ",#b2, ", Temp3: ",#b3, cr,lf)
return

negb2:

let b2 = b2 - 128
sertxd ("Temp1: ",#b1, ", Temp2: -",#b2, ", Temp3: ",#b3, cr,lf)
return

negb3:

let b3 = b3 - 128
sertxd ("Temp1: ",#b1, ", Temp2: ",#b2, ", Temp3: -",#b3, cr,lf)
return

buzz:

Sound 2,(125,50)
sertxd ("Temp1: ",#b1, ", Temp2: ",#b2, ", Temp3: ",#b3, cr,lf)
let b9 = 1
return

back:
return

Hope it can be useful to someone. Its probably not the best code but im learning. Any ideas on this are welcome.
 

BCJKiwi

Senior Member
Just a suggestion (in the light of your student status rather than the actual solution);

How would more than one negative temp be displayed?

Think in terms of building up each temp variable and a flag for + or - one at a time and then only having one sertxd line at the end.
 

kam

Member
Code Improved

Just a suggestion (in the light of your student status rather than the actual solution);

How would more than one negative temp be displayed?

Think in terms of building up each temp variable and a flag for + or - one at a time and then only having one sertxd line at the end.

Alright This is what i've come up with so far. now it checks if there are two readings going negitive and will display them. but i still think there must be a better way of doing this. have a look.

Code:
main:

pause 750
readtemp 1,b1
readtemp 0,b2
readtemp 7,b3

if b1 < 127 and b2 < 127 and b3 < 127 then gosub out

let b9 = 0

gosub negout

goto main

out:
if b2 = b1 then gosub buzz
if b9 = 1 then back
sertxd ("Temp1: ",#b1, ", Temp2: ",#b2, ", Temp3: ",#b3, cr,lf)
return


negout:

if b1 < 127 and b2 < 127 and b3 < 127 then back

if b1 > 127 then let b1 = b1 - 128 and b4 = 1
if b2 > 127 then let b2 = b2 - 128 and b5 = 1
if b3 > 127 then let b3 = b3 - 128 and b6 = 1

if b4 = 1 then sertxd ("Temp1: -",#b1)
else if b4 = 0 then sertxd ("Temp1: ",#b1)
let b4 = 0


if b5 = 1 then sertxd (", Temp2: -",#b2)
else if b5 = 0 then sertxd (", Temp2: ",#b2)
let b5 = 0

if b6 = 1 then sertxd (", Temp3: -",#b3,cr,lf)
else if b6 = 0 then sertxd (", Temp: ",#b3,cr,lf)
let b6 = 0

return

buzz:

Sound 2,(125,50)
sertxd ("Temp1: ",#b1, ", Temp2: ",#b2, ", Temp3: ",#b3, cr,lf)
let b9 = 1
return

back:
return
 

BCJKiwi

Senior Member
You can put an ascii + or - into b4,b5,b6, then you don't need the additional if b4 etc tests, just output and show + or - in the output.
 

BCJKiwi

Senior Member
Well this is what I had in mind;
It is more complicated than expected as a zero temp has a - sign unless some extra work is done.
If I was doing this I would prefer to see;
a + for positive temps,
no sign for 0
and a - sign for negative temps.

Pseudo code - have to leave the work for you but have tested a program based on this description - is 40 lines long and 157 bytes.
You've not indicated the chip but this would easily fit in an 08m up but as you have an input pin 7 it must be at least a 20M or 28x1.

main:
pause 750
set default sign to a "+" for b4,b5,b6
set default sound frequency to 0

read temps into b1, b2, b3
for each temp in turn,
test to see if neg and if so -128,
test new result to see if > 0 and if so change default sign to a "-"
or if 0 change default sign to a space " "

test b1 = b2, if so, change sound default to 125,

output sound
output text, sign, value, text, sign, value, text, sign, value

goto main
 
Last edited:

manuka

Senior Member
Us boring old helpers would appreciate a picture of how your final layout looked, along with sample results etc. How did your teacher react?!
 

kam

Member
Im using a 18x. the idea is that it takes the PICAXE 750ms to read and compile the output from the sensors and because there are 3 of em, that adds up to be 2.25s so i added a pause of another 750 to make it a reading of complete 3 sec. just easier

Now as far as the temp read sign goes. I find there is no need to put a +ve sign infront of a +ve number. But for the -ve sign... yes.

The output looks like this:

Temp1: 22, Temp2: 2, Temp3: 20
Temp1: 22, Temp2: 2, Temp3: 20
Temp1: 22, Temp2: 2, Temp3: 20
Temp1: 22, Temp2: 1, Temp3: 20
Temp1: 22, Temp2: 1, Temp3: 20
...........................................
........................................... and so on

I know that an ice sample will hardly go below 0 as the freezer can usually go to -6. I found it easier to just check for a certain condition and if true send it to a subroutine, which tells it to send the data out in a certain format.

the code is a few posts up.

PS: My teacher reacted well as they found everything working.
Kam
 
Last edited:
Top