View Full Version : PicAxe Simulator ...continued2
Good work so far Jeremy.
Are you still developing this software?
or has the need subusided after completion of your calculator project?
edit: still taking bug reports?
Edited by - k_man on 1/18/2006 8:10:17 PM
Jeremy Leach
19-01-2006, 09:11
Hi - I've not done anymore for a while ... been in circuit design mode recently .. Happy to take Bug reports - probably best by email. I still am going to use this for a lot of my software development as it's helped me already.
Hi,
just got to using your simulator to get a handle on a bug in a tricky piece of code. It's a BIG help. Now I'd have a few questions and/or suggestions:
(1) The simulator insists on
if..then label
while the real program editor wants to see
if...then goto label
What gives?
(2) What's the correct way to modify variable contents? E.g. let's say I want to change b0 from its current value (e.g. 5) to something else (e.g. 123). I tried to enter 123 in the "unsigned" value field on the "Variables" worksheet and the programs seems to use that, but neither the "signed" field nor w0 nor any symbols defined as "...=b0" get updated. What am I doing wrong?
Being able to modify variables would be a treat since it would allow much more powerful debugging.
(3) It would be great if one could enter values for the states of the input pins, e.g. in the input port fields on the "Variables" worksheet. I tried to do that but the simulator seems to ignore that; e.g.
let b0 = pins
always yields 0. And
if pin0 = 1 then ...
always behaves as if pin0 were low.
All that notwithstanding, a great piece of code!
Wolfgang
Edited by - womai on 2/10/2006 4:13:33 AM
Bloody-orc
10-02-2006, 06:52
1) you may not use goto in that line as far as i know...
2) let b0 = 123 b0 has now the value of 123
3) there is a tab to change the pin values as far as i know...
1) you may not use goto in that line as far as i know...
well, my program editor definitely wants it there. Gives me an error otherwise. I was simulating a program that compiles and downloads fine on the real hardware, so I know the syntax works there. You cannot use gosub in an if statement (which is mightily annoying and makes for clumsy code), that's probably what you remembered?
2) let b0 = 123 b0 has now the value of 123
I know of course how to do it in the code. But that's not what I want - I don't wan't to change the program code. I'd like to do on-the-fly changes in the simulator/debugger. (that's a standard feature in any "real" debugger.)
3) there is a tab to change the pin values as far as i know...
Yeah, but I tried to set the values of the input pins, but that didn't change the result of the "let b0=pins" statement... I'm using Excel 97 if that makes a difference.
Actually one more request, any chance to expand the simulator to cover the 28X and 40X as well?
Wolfgang
Jeremy Leach
10-02-2006, 08:38
Hi. I've been deeply into circuit ideas recently. I'll try to get my head around your points and get back to you. As for expanding it - I've only personally used the 08M and 18X PICAXEs. There's no reason why I can't expand it - just time !
Bloody-orc
10-02-2006, 09:41
2) well as it is a simulator not a debugger it just shows you what the poicaxe does. and as far as i know you cant change the variables without a code lines... if you can please notify me also...
1) and as i know it doesnt want that line (mine shurely doesen't)
Technical
10-02-2006, 11:04
if...then...
if...then goto...
are both ok (the optional goto is often used by younger school students as it helps them understand the 'jump')
if...goto...
is not allowed.
Jeremy Leach
10-02-2006, 14:42
Hi
I ommitted the syntax "if .. then goto label". I'll update it.
I had intended that you can modify variables manually as you step through code, but it isn't working quite right is it ! Changes aren't rippling through - but I should be able to fix it.
Jeremy Leach
13-02-2006, 11:24
I've put version 1S on my website
<A href='http://home.btconnect.com/PicAxe_Projects/PicAxeSim.htm' Target=_Blank>External Web Link</a>
This now allows if...then...goto
It also allows variable values to be specified while code is being stepped through : either via the sybol or variable sheets.
pin values can be specified either on the chip or variables sheet.
Hopefully now works as you want it to.
Bloody-orc
19-02-2006, 17:44
hey! it's me again.
anyways. another good idea to ad into T version is random generated ADC values on adc pins. so that i give it a speciffic rang it will random in and then i can see what my program does when a speciffic adc value comes up.
until version S everything eems to be good...
Jeremy Leach
20-02-2006, 09:24
Ok, I'll think about that. Would a 'virtual-potentiometer' do, which applies a selectable voltage to a selected pin ? I don't see that a random value would help ??
Did you mean everything is still ok with version S or has it caused new problems?!
Edited by - Jeremy Leach on 2/20/2006 8:37:46 AM
Jeremy Leach
20-02-2006, 15:49
Version 1T on my website <A href='http://home.btconnect.com/PicAxe_Projects/PicAxeSim.htm' Target=_Blank>External Web Link</a>
Now allows manual input of ADC values when using Readadc and Readadc10 commands.
Bloody-orc
20-02-2006, 17:47
Symbol vjoon = b1
Symbol vasakjoon = 1
Readadc vasakjoon,vjoon
type mismach error
Jeremy Leach
20-02-2006, 18:30
Oops ....sorry Bloody. Now works - hopefully ! (updated version T on website ;-)
Bloody-orc
20-02-2006, 21:06
now it ses invalid pin number (soft same as abouve)
(i'm sorry to complaint all the time...)
Jeremy Leach
20-02-2006, 21:24
Invalid pin number is a valid response - on a 18X ADC can only be pin 0,1,2 and on an 08M pin 1,2,4. If you are trying to use anything different then it will report invalid pin number. Make sure you've selected the right PIAXE version on the config sheet.
Bloody-orc
21-02-2006, 08:31
wellk it seems that the ADC read command that i have doesn't change the variables so the next line does nothing and gives me wrong results... no variable is changing
<code><pre><font size=2>
Symbol vasakjoon = 1
Symbol paremjoon = 2
Symbol temp = b0
Symbol vjoon = b1
Symbol pjoon = b2
Symbol anduritevahe = 20
Symbol tagasi_s = 25
Symbol paremale = 20 '"slow" 4 00 0101 00
Symbol vasemale = 40 '"slow" 32 00 1010 00
Symbol otse = 36 '00 1001 00
Symbol tagasi = 24 '00 0110 00
Setfreq m8
Wait 5
main:
'debug
Readadc vasakjoon,vjoon
Pause 10
Readadc paremjoon,pjoon
Pause 10
If vjoon < pjoon Then _vjoon
If vjoon > pjoon Then _pjoon
_vjoon:
temp = pjoon - vjoon
If temp > anduritevahe Then _joonvasakul
Goto _otse
_pjoon:
temp = vjoon - pjoon
If temp > anduritevahe Then _joonparemal
Goto _otse
_joonvasakul:
pins = tagasi
Pause tagasi_s
pins = vasemale
Goto main
_joonparemal:
pins = tagasi
Pause tagasi_s
pins = paremale
Goto main
_otse:
pins = otse
Goto main
</font></pre></code>
Jeremy Leach
21-02-2006, 10:13
Sorry Bloody. It was another slight error in my code. Now updated on my website, and your code now picks up the ADC values.
Bloody-orc
21-02-2006, 14:52
i'm sorry to inform you that when i read ADC value 186 the variable gets a value of 46 i qualify this as an error ;)
Jeremy Leach
21-02-2006, 15:01
Well, for once actually this isn't an error.
The ADC values you type in on the'chip' sheet are in the range 0 to 1023 (10 bit). If you use the ReadADC command this is only 8 bit so it scales the value down to be in the range 0 to 255. (186 /1023) * 255 = 46.
Bloody-orc
21-02-2006, 19:40
ok thanks for making that clear. so in this simulator i must use readadc10 all the time...
Jeremy Leach
22-02-2006, 08:55
Bloody ....no you can use either Readadc or Readadc10 commands, but in terms of the data you feed into the ADC this is 10 bit.
Bloody-orc
22-02-2006, 09:17
ok
Bloody-orc
27-02-2006, 21:57
GUESS WHO!
command
Serin RX_PIN,RX_BAUD,(PREAMBLE_BYTE,SOM_BYTE),code...
gives an error on invalid baudrate
codesnipet from hippy's RF tutorial (That i got to work with my hardware after 2 years of waiting and searching time to work with)
Just spotted that this also aplies to SEROUT command
Edited by - bloody-orc on 2/27/2006 8:58:33 PM
Jeremy Leach
28-02-2006, 15:34
Thanks for picking up on this Bloody. It was an issue relating to pre-defined constants.
Now corrected in version 1V !!
Bloody-orc
28-02-2006, 21:59
i dont get it. i just downloaded the program a second after you uploaded it to your page and it doesn't correct that problem at all.
(btw you are running out of letters. just 3-4 more to go...)
Jeremy Leach
01-03-2006, 09:28
Well this works on Version 1V, as a test ...
<code><pre><font size=2>
Symbol RX_PIN = 1
Symbol RX_BAUD = N2400
Symbol PREAMBLE_BYTE = %10101010
Symbol SOM_BYTE = "Z"
Serin RX_PIN,RX_BAUD,(PREAMBLE_BYTE,SOM_BYTE),b0
</font></pre></code>
PS Don't worry, It'll soon be V "2"A ..etc ;0)
Edited by - Jeremy Leach on 3/1/2006 8:29:56 AM
Bloody-orc
01-03-2006, 10:57
it seems it is the problem of me having a baud rate of 2400 not T/N2400. and as it works so this should be enabeled also.
thank you
Jeremy Leach
01-03-2006, 11:26
Ah ...that's interesting. I've gone from the definitions in the manual, and my manual doesn't mention 2400, just N2400 or T2400 (see under Serin or Serout). However the PICAXE Editor does accept 2400.
I think I'll stick to N and T varieties only to conform with the documentation.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.