So many axevsm errors that don't error on the programming editor

tiscando

Senior Member
I have picaxe vsm with a licence key and the latest axevsm dll (1.0.3 or like that).
I have encountered a lot of problems when i try to run codes in vsm's picaxe chips, yet they run o.k. on the programming editor's simulator. here is a list of them...

1. [08m] in this code's if structure, even though all the 08m's input pins are high, the code just skips the if pin=1... line and does the code inside, and as the code touches the first elseif, it errors. [this is an oscillator for dtff phone tones.]
Code:
startup:
setfreq m8
nap 1
gosub interrupt
goto main

interrupt:
if pin1=0 then '0.81
let b0=62 '0.31
setint %00000010,%00000010

elseif pin2=0 then '0.74
let b0=48 '0.24
setint %00000100,%00000100

...2 more elseifs the same

else
goto interrupt

endif
return

main:
pause 1 '0.5
pulsout 0,b0
goto main
2. [08m] I have changed the above code to this... Still erroring as it hits the if pin1=0 line, regardless of the pin state.
Code:
startup:
setfreq m8
nap 1
gosub interrupt
goto main

interrupt:
if pin1=0 then goto s1'0.81
if pin2=0 then goto s2'0.74
if pin3=0 then goto s3'0.67
if pin4=0 then goto s4'0.60
goto interrupt

s1:
let b0=62 '0.31
setint %00000010,%00000010
return

s2:
let b0=48 '0.24
setint %00000100,%00000100
return

s3:
let b0=34 '0.17
setint %00001000,%00001000
return

s4:
let b0=20 '0.10
setint %00010000,%00010000
return

main:
pause 1 '0.5
pulsout 0,b0
goto main
(still the same error if i remove the 'goto's from the 'if' commands)

3. [08m] the code just goes past all the if commands regardless of the pin state, and gets stuck on the pulsout command, staying on it throughout the simulation, not moving on. If I remove the setfreq command, the code gets stuck on the first If command regardless of pin state.
Code:
startup:
setfreq m8
nap 1

main:
if pin1=0 then s1'0.81
if pin2=0 then s2'0.74
if pin3=0 then s3'0.67
if pin4=0 then s4'0.60
goto main

s1:
pause 1
pulsout 0,62 '0.31
if pin1=1 then main
goto s1

s2:
pause 1
pulsout 0,48 '0.24
if pin2=1 then main
goto s2

s3:
pause 1
pulsout 0,34 '0.17
if pin3=1 then main
goto s3

s4:
pause 1
pulsout 0,20 '0.10
if pin4=1 then main
goto s4
4. problem not related to picaxe: on the keypad, current wouldn't come through any particular pins linked to a button even if i click on the button, e.g. on the phone keypad, even if i click on button 2 (looking like it's pressed in), no current comes through pins 2 and A, so it doesn't behave like how i have studied a phone keypad in my phone.
 
Last edited:

Technical

Technical Support
Staff member
1 to 3. Please post your .dsn design file. There is probably an issue on this somewhere, without it it is hard to troubleshoot the errors.
4 The keypad model is a purely digital model, not an analogue model. Therefore you only get high/low signals, not current flow. However these high/low signals will still activate the PICAXE inputs.
 

tiscando

Senior Member
This 08m picaxe template of my own is where i have tested all my programs mentioned in my other post.

more problems:

5. won't move anywhere from this 'if' command at all.

main:
if pin1=0 then high 0 endif
if pin2=0 then low 0 endif
goto main


6. also stuck on the same 'if'
Code:
startup:
nap 1

main:
if pin1=0 then sw10
if pin2=0 then sw00
goto main

sw10:
high 0
goto main

sw00:
low 0
goto main
Actually, the bit at the start of every program i have tried is causing the problem.

Re: 4. i found that the keypad works on pulling up/down a picaxe pin, but it wouldn't supply a voltage to a transistor's base, nor turn on the transistor, unlike a normal button switch.
 

Attachments

Last edited:

tiscando

Senior Member
Actually, the bit at the start of every program i have tried is causing the problem.
I always had this bit at the start:

startup:
(setfreq m8) this line is only sometimes inplemented.
nap 1

main:
(code)

...and that bit is causing errors and sticks in the picaxe vsm, but not a problem on the picaxe editor and a real-life picaxe chip.

This means my programs that i have copied to post #1 and #3 actually work if i remove the 'nap 1' command, yet the programming editor does accept the nap command at the start. the pause 50 command i now put in works fine in vsm, as i need it as a delay to let the power rails stabilise.
 
Last edited:

tiscando

Senior Member
I still have the latest axevsm dll. I have found another codal problem
In a debugging circuit with 2 14m picaxes and a 40x1, some pause commands don't work, causing serial errors between the picaxes. I am using a custom-made serial protocol like this: (i found the evidence by looking at the elapsed time, and when i step through the 'pause tnpre' command, the elapsed time doesn't count up a millisecond, and that means it goes straight to the serout command and starts transmitting '21' when one of the 14m's have only almost entered the serin command, recieving no or corrupted data.:mad:


symbol ents=21
...
high tnsout
do
loop until tc=1 and tr=1
pause 1 'this command doesn't pause. entering higher values makes no difference either.
high tnsout
serout tnsout,t4800,(ents)
pause 1 'this one works o.k.
low tnsout
...

Full code: (40x1)(the only bits that matter)
Code:
symbol power =7
symbol confl =6
symbol ringfl=5
symbol flsout=4 'serout n600
symbol contl =3
symbol ltone =2
symbol tnsout=1 'serout t4800
symbol spring=0

symbol handset=pin0
symbol tlring =pin1
symbol flans  =pin2
symbol offhook=pin3
symbol flsin  =3 'serin t600
symbol DV     =pin4
symbol tc     =pin5
symbol tcsin  =5 'serin t4800
symbol tr     =pin6
symbol trsin  =6 'serin t4800
symbol spsshh =pin7

'14m controllers:
symbol dists=20 'disable tone serial sending
symbol ents=21  'enable  tone serial sending

symbol spkroff=3
symbol spkron=13

symbol tnpwroff=4
symbol tnpwron=14

symbol drbeloff=5
symbol drbelon=15

symbol flbypoff=6
symbol flbypon=16

'fake line code:
symbol flret=10
symbol floudspkr=11
symbol flrng=12
symbol frngflash=13
symbol flashidle=14
symbol frngtone=15
symbol fautorngtone=16
symbol flstatus=19
symbol fnetoff=20
symbol fneton=21
symbol fnetrestart=22

symbol allf=9

'pauses:
symbol tnpre=100
symbol tnpost=1
symbol flpre=100
symbol flprex=60
symbol flpost=2
'timeouts:
symbol tntout1=30
symbol fltout1=50

'tones:
symbol tnerror=115
symbol intprc=119
symbol intcom=121
symbol afterthetone=125

let pins=%00010000
i2cslave $c4,i2cfast,i2cbyte

standby:
if handset=1 then handoffhk
if tlring=1 then tlinring 
if offhook=1 then floffhk
goto standby


doorbell:
serout tnsout,t4800,(drbelon)
pause 300
low tnsout,power
goto standby


floffhk:
b13=0
serin [30,fltout],flsin,t600,b13
fltout:
high power,tnsout
do
loop until tc=1 and tr=1
pause tnpre
if b13=30 then doorbell
floffhk2:
serout tnsout,t4800,(tnpwron)
pause tnpost
high tnsout
do
loop until tc=1 and tr=1
pause tnpre
high tnsout
serout tnsout,t4800,(ents)
pause tnpost
low tnsout
high confl
if bit0=1 then tonestar 'answer phone
goto wait4tone

handoffhk:
low confl
high tnsout,power
do
loop until tc=1 and tr=1
pause tnpre
serout tnsout,t4800,(flbypon)
pause tnpost
high tnsout
do
loop until tc=1 and tr=1
pause tnpre
serout tnsout,t4800,(tnpwron)
pause tnpost
high tnsout
do
loop until tc=1 and tr=1
pause tnpre
serout tnsout,t4800,(ents)
pause tnpost
low tnsout
handret:
do
if tc=1 and tr=1 then sertone
if tlring=1 then pulsout spring,100 endif
loop until offhook=1
high tnsout      'fake line off hook
do
loop until tc=1 and tr=1
pause tnpre
serout tnsout,t4800,(flbypoff)
pause tnpost
low tnsout
high confl

wait4tone:
if offhook=0 and handset=1 then handoffhk
if offhook=0 then 
	if handset=1 then handoffhk
	low power,confl
	goto standby
endif
if tc=1 and tr=1 then sertone
if tlring=1 then pulsout ltone,100 endif
if dv=1 then tonin
goto wait4tone

tonin:
...
...

sertone:
high tnsout
pause 1 'this doesn't work either.
serout tnsout,t4800,(1)
serin [tntout1,sertone],tcsin,t4800,b10
tryagn2:
pause 10
serout tnsout,t4800,(2)
serin [tntout1,tryagn2],trsin,t4800,b11
pause 10
serout tnsout,t4800,(3)
pause 5
do
loop until tc=0 and tr=0
let b10=b10-1
let b11=b11-1
branch b10,(c1,c2,c3)
goto invalid

c1:
branch b11,(tone1,tone4,tone7,tonestar)
goto invalid

c2:
branch b11,(tone2,tone5,tone8,tone0)
goto invalid

c3:
branch b11,(tone3,tone6x,tone9,tonehash)

invalid:
sound ltone,(tnerror,50)
goto wait4tone

tone1: 'ring phone 1
...
dtmf tone columns: (1st 14m)
Code:
setfreq m8
pause 5

main1:
if pin0=1 then gosub readbuf
if pin1=0 then
	let b6=21
	let b7=20
	let b4=1
	goto tone '0.81
elseif pin2=0 then
	let b6=18
	let b7=16
	let b4=2
	goto tone '0.74
elseif pin3=0 then
	let b6=14
	let b7=13
	let b4=3
	goto tone '0.67
elseif pin4=0 then
	let b6=10
	let b7=9
	let b4=4
	goto tone '0.60
endif
goto main1


tone:
if b3=1 then gosub readbuf
b4=0
do
	pulsout 1,b6
	pulsout 0,b7
	if pin0=1 then gosub readbuf
loop until pin1=1 and pin2=1 and pin3=1 and pin4=1
low 2
goto main1


readbuf:
high 2
if pin0=0 then readbuf
serin 0,t4800_8,b1
if b1<>1 then low 2 endif
select b1

case 1
pause 1
serout 2,t4800_8,(b4)
goto readbuf

case 2
pause 2
goto readbuf

case 12
return

case 3
low 3

case 4
low 4

case 5
low 5

case 13
high 3

case 14
high 4

case 15
high 5

case 20
let b3=0

case 21
let b3=1

endselect
pause 3
if pin0=1 then readbuf
low 2
return
dtmf tone rows: (2nd 14m)(same as tone columns, but...)
Code:
if pin1=0 then '1.47
	let b6=52
	let b7=51
	let b4=1
	goto tone
elseif pin2=0 then '1.35
	let b6=45
	let b7=44
	let b4=2
	goto tone
elseif pin3=0 then '1.22
	let b6=39
	let b7=38
	let b4=3
	goto tone
elseif pin4=0 then '1.06
	let b6=33
	let b7=32
	let b4=4
	goto tone
endif
goto main1
...
...

serin 0,t4800_8,b1
if b1<>2 then low 2 endif
select b1

case 1
pause 2
goto readbuf

case 2
pause 1
serout 2,t4800_8,(b4)
goto readbuf

case 12
return

case 6
low 3

case 7
low 4

case 8
low 5

case 16
high 3

case 17
high 4

case 18
high 5

case 20
let b3=0

case 21
let b3=1

endselect
...
 

Attachments

Last edited:

Technical

Technical Support
Staff member
Your source code is incomplete and the dsn very complicated. Please post a much simpler complete example that shows the issue.

Also, remember that when running more than one chip on a design and stepping through code that the code on all 3 chips must be processed (stepped through) before the elapsed time will change.
 

tiscando

Senior Member
On the main program, some pause commands are skipped, e.g. the program goes to the next line after the pause 1 command while the other picaxe is still on a command e.g. 'if pin0=0 then readbuf' and the time doesn't go up a full millisecond either.
I have created a debug version, and the pauses worked properly.

40x1 serial debug:
Code:
b2=13
gosub send
gosub waitin
b2=14
gosub send
gosub waitin
b2=15
gosub send
gosub waitin
b2=3
gosub send
gosub waitin
b2=4
gosub send
gosub waitin
b2=5
gosub send
do
if pin5=1 then gosub readbuf
loop
end

waitin:
for b1=1 to 250
if pin5=1 then gosub readbuf
pause 2
next b1
return

send:
high 1
do
loop until pin5=1
pause 2
serout 1,n4800,(b2)
pause 1
low 1
pause 10
return

readbuf:
high 1
pause 2
tryagn:
serout 1,n4800,(1)
serin [100,tryagn],5,n4800,b3
low 1
let outpins=b3<<2
pause 10
return
14m serial debug:
Code:
setfreq m8
pause 5

main1:
if pins<>b0 then gosub readbuf
pulsout 1,100
pause 1
goto main1


readbuf:
high 2
if pin0=0 then readbuf 'significant from main program.
serin 0,n4800_8,b1
if b1<>1 then low 2 endif
select b1

case 1
let b0=pins
let b0=b0 and %00011110'serial/absent pins
serout 2,n4800_8,(b0)

case 3
low 3

case 4
low 4

case 5
low 5

case 13
high 3

case 14
high 4

case 15
high 5'!

endselect
pause 3
if pins<>b0 then readbuf
low 2
return
edit: has anyone sorted out the 'nap' command problem as described near the start of this thread?
 
Last edited:

tiscando

Senior Member
trouble with the keypads

I am having lots of trouble trying to get the keypad to just work.
see the attachment:
the top-right keypad has a simple trasistor-based detector on pin D, and on pin 1, is just connected to vcc. pressing the bottom-left button makes the logic probe '0' on the letter side, and what about the number side? so looking at the left keypad, it also has a transistor-based detector between vcc and the pin, but pressing the relevant button doesn't do anything. so i mean, how the :confused: can i make the whole keypad work properly with a logic circuit or a picaxe, and not just whole columns or rows of buttons doing the same effect. a button switch seems to work more easier than a single keypad button for the two transistor based detectors at each side of the button.

the only way round this is to connect the keypad to a key encoder. but what about the keypads larger than 4x4. i created the circuit at the bottom-right exactly according to one of the examples in the mm74c922's datasheet. the first 4 columns work fine, but the 2 at the right which are connected to the extender circuit don't work, but oscillate instead, which means there is no correct data outputted by the i.c. for those 2 columns.

can anyone make the keypad just behave like the button-switch matrix I have created at the bottom-left of the design, and which works with the transistor circuit like at the top-left.
 

Attachments

Technical

Technical Support
Staff member
This confused us for a while aswell. According to Labcenter the keypad model in proteus is a 'digital model', not an 'analogue model'. Therefore no current will flow through it. It simply reacts to high/low signals, not current flow.

So to model with PICAXE simply connect directly to i/o lines without transistors etc.
 

tiscando

Senior Member
Improper program flow.

I am getting unusual simulation problems here.

!. The Vsm's picaxe program simulation pointer (a brown arrow) doesn't always stay on It's path. this is true for the select/case/endselect command, e.g.

main: 'top of program
...
...
...
select b5
case 1
...
...
case 2
...
...
case 3
...
...
...
else
...
...
endselect
...
...

If b5 is 2, then the pointer would come down onto the 'select' command, and then onto 'case 1', and it doesn't mach b5's value, so it goes onto the next case, but rather than coming straight onto it, the pointer jumps to the top of the program on one press of the 'step in button', before pointing at the 'case 2' line on another press of the step button. PE's simulator would go straight to 'case 2' from 'case 1' if b5 doesn't mach, and on vsm's program, the problem described really annoys me.
It is the same for the 'high' and 'low' commands, e.g.

main: 'top of program
...
...
...
high 7,5,4,3,1,0
...

when the pointer enters the 'high' command, the pins specified would be set high one at a time for each press of the 'step in' button in the specified sequence, but while it does that, the pointer doesn't stay on the 'high' command, but goes to the top of the program, while it's executing, then come to the line after this command.


". I was interfacing the circuit in thread:)How to get the keypad to work, when I finally found use in the keypad, with a graphical lcd circuit.
see the " programs at the bottom and the " attachments.
I modified the keypad master program to serout to the picaxe controlling the graphical LCD, so it looks like the second attachment. I am getting problems at the far bottom of the program, as follows:

if typrel=1 then shpse
pause 1000
typrel=1
goto main1 '#1

shpse:
pause 200
goto main1 '#2

A. when the pointer enters 'goto main1 '#1', it doesn't jump to the label 'main1:', instead, the window greys out, and says
no source line at pc address [pc=0000]
and when I click on run, the simulation terminates and the error log pops up, saying:
Potential race condition: pin=U3_U1:eek:ut0, net=#00058, state=
Potential race condition: callback=00000002
Potential race condition: callback=00000002
Potential race condition: callback=00000002
Potential race condition: callback=00000002
Potential race condition: pin=U3_U1:eek:ut0, net=#00058, state=
Potential race condition: callback=00000002
Potential race condition: pin=U3_U1:eek:ut0, net=#00058, state=
Potential race condition: callback=00000002

Race condition detected.

B. I added the nap 1 command at the very start of the keypad program. the problem then becomes very different. entering the 'goto main1'#1' in the code snippet above does this instead:
no source line at pc address [pc=6c86] 'every time I click 'step in', the hex number goes up by 8. clicking run, and then pause, the pc address is stuck at 014d. see the nap command problem described at the start of this thread.

C. Earlier, I had this:
if typrel=1 then
pause 200'#1
else
pause 1000'#2
typrel=1
endif
goto main1
replacing the above snippet. It worked fine, but the pauses are rather erratic.
the second pause seems to pause the same time as the first one.

D. If I put the 'nap 1' command in the program the same as described with C.,
The pointer gets stuck at the 'pause 1000' command 'forever'.


keypad slave1 serial.bas
Code:
setfreq m8
high portc 0,1,2,3,4,5,6,7
main:
serin 0,n4800,b2

select b2
case 254
	let dirsc=0
	pause 1
	if portc pin7=1 then 
		b3=1
	elseif portc pin6=1 then
		b3=2
	elseif portc pin5=1 then
		b3=3
	elseif portc pin4=1 then
		b3=4
	elseif portc pin3=1 then
		b3=5
	elseif portc pin2=1 then
		b3=6
	elseif portc pin1=1 then
		b3=7
	elseif portc pin0=1 then
		b3=8
	else 
		b3=255
	endif
	serout 0,n4800,(b3)
	low 0
case 200
	high portc 0,1,2,3,4,5,6,7
case 201
	let dirsc=0
endselect
goto main
keypad slave2 serial.bas
Code:
setfreq m8
high portc 0,1,2,3,4,5,6
main:
serin 0,n4800,b2

select b2
case 253
	let dirsc=0
	pause 1
	if portc pin6=1 then
		b3=1
	elseif portc pin5=1 then
		b3=2
	elseif portc pin4=1 then
		b3=3
	elseif portc pin3=1 then
		b3=4
	elseif portc pin2=1 then
		b3=5
	elseif portc pin1=1 then
		b3=6
	elseif portc pin0=1 then
		b3=7
	else 
		b3=255
	endif
	serout 0,n4800,(b3)
	low 0
case 200
	high portc 0,1,2,3,4,5,6
case 201
	let dirsc=0
endselect
goto main
 

Attachments

tiscando

Senior Member
E. If I change pause 1000 to pause 500, and pause 200 to pause 100 on the code described with C, the pointer gets stuck on 'typrel=1', and than says no source line [pc=4020] 'forever'. If it's pause 600, then it errors exactly like described with A.
If it's pause 800, then it gets stuck at 'goto main1', and then displays no source line [pc=4036].
If it's pause 900, it gets stuck at 'goto main1', and when I click 'run', the error log suggested that U3 polled in3 twice, and did a readadc 0 command, and then did a keyled command, and the debug window showed 'no source line [pc=A185]'.
IF it is pause 700, it does one of the two things:
if I press a key on the left side of the keyboard, it gets stuck at 'goto main1', and on clicking run, I get
Internal Exception: access violation in module in axevsm1.dll.
If I press a key on the right side of the keyboard, the pointer goes to that same ***** old goto main1, and then the error log suggested it has polled in3, and displays ...[pc=4041], and every time I click the step in button, the number goes up by 14, until it does a 'reset' command, when it's back to normal, but that's how it shouldn't work.
If it is pause 400, the pointer just gets stuck at 'typrel=1' 'forever'.
If it is pause 300, entering goto main1 again, the simulation terminates with the error log saying stack underflow.
If it is pause 200, then entering goto main1, it displays ...[pc=4016]

pause 1000 is the 'lowest' one that works correctly. that pause value seems really dependant on the above problems. anything between the many pause values mentioned above would produce similar symptoms near the corresponding described problem.

Same problems when I add a few 'low' commands between endif and the troublesome goto main1.
If i add 5 'goto main 1's then it gets stuck at 'typrel=1' for a bit, and then gets stuck at the second goto main1 down.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
********************************************************
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I mean, what the :confused: is going on?
Technical, is this more than enough evidence:eek: for that dodgy area of the vsm picaxe program runner?
It all works fine on the programming editor's complier and simulator, obviously:rolleyes:.
I looked again and I have axevsm dll's version 1.0.3. I have windows vista, just to clarify.

If I change any other pauses anywhere in the program, different problems like described above occur too.
 
Last edited:

Technical

Technical Support
Staff member
We'll have a look into this for you, we are working on the next release of VSM at the momemnt.
 

tiscando

Senior Member
I've also noticed something odd in the error log window on startup. For 40x1s, the validation always says this:
Program size: 256 bytes out of 4096 (6%)
No matter how much program space use is actually recorded in PE's syntax check, from small to large.

Tecnical in post #21 referred to post #13, but due to editing and a post deletion, he actually refers to post #12 above.
 
Last edited:

tiscando

Senior Member
bug with lookdown command

I found a bug with the lookdown command. The problem is that the last value isn't checked, e.g. when b4 is initially 1, and b2 is %10000, b4 stays the same, whereas for the other values before this, it works fine. I was using a 40x1.
So, my workaround is to add an incorrect value after the last value.

lookdown b2,(%00000,%01000,%11000,%10000),b4
lookdown b3,(%011,%001,%101,%100,%110,%010),b5

And, according to this thread's title:p, it all works fine on PE's simulator... ... .
 
Last edited:

tiscando

Senior Member
Confusion with the BLDCMotor

I had a look at the BLDCM and there is something odd.
!. The motor has 3 poles, but it doesn't behave like it should at all. adding a voltage on any of the poles and then the motor spins one way like a brushed DC motor, even with all 3 pins at +V, rather than attracting to a particular position.

I would probably get an SDK at some time.
 

tiscando

Senior Member
The readportc command is a syntax error to the vsm, but works well on PE's simulator.
 
Last edited:

tiscando

Senior Member
the 'let portc=?' on picaxe vsm makes the whole port C outputs when not really supposed to, but the 'let dirsc=%11111111 doesn't make them outputs. the 'let portc=?' command on PE's simulator doesn't change the inputsC to outputsC, which I assume is correct.
 
Last edited:

tiscando

Senior Member
another invisible glitch

See the code and the attached command.
In the terminal window, I type in "wrb 10110110", and pressed enter, and as the program proceeds, in the bin8 (& bin5) sub, the program flow pointer goes onto the last 'case 49' down the program, and says "No source line...[pc=4631], and every time I click the step button, the pc address increments by $0E (14), and when I click the 'run' button, the error log pops up saying "Internal Exception: access violation in module 'AXEVSM1.DLL'.".

If I type in "wrb 11010011", then the above happens, but when I click run, then pause after a second, then the code window says "no source line...[pc=40F1]".

Code:
symbol rd=7 '0=read enabled
symbol wr=6 '0=write enabled
symbol a0=5 '1=data, 0=command
symbol ao=5
symbol rst=4'0=chip reset
symbol tso=0
symbol ts0=0

symbol tsi=0

symbol sd=b3
symbol cga=b13

symbol busy=bit23
symbol adc=bit22
symbol donf=bit21
symbol hres=bit20

symbol ent=$0d
symbol bksp=8
symbol clr=12
symbol spmk=34

#rem timing characteristics:
aft c/d change, bef ce low   = 150ns
aft ce high, bef c/d change  = 20ns
ce.rd.wr pulse width         = 100ns
aft valid data, bef ce high  = 100ns
aft ce high, bef data reset  = 50ns
aft ce.rd low, bef valid data = 150ns

status check: rd=0,wr=1,ce=0,cd=1,portc:
pin0: 1=able to execute command
pin1: 1=able to data read/write
pin2: 1=auto mode able to data read
pin3: 1=auto mode able to data write
pin5: 1=controller able to operate
pin6: 1=error in screen peek/copy command
pin7: 

command definitions:


valid picaxe register addresses: 80-126,192-239
#endrem

let pins=%11000001
hspisetup spimode11e,spimedium
pause 1
high rst
pause 500

main:
for b5=80 to 126
	poke b5,0
next b5
b4=80
serout ts0,t4800,("-> ")
main1:
serin tsi,t4800,sd
if sd=ent then readcommand
if sd=bksp then
	if b4<81 then main1
	dec b4
	poke b4,0
	serout tso,t4800,(sd)
	goto main1
elseif b4<80 then 
	b4=80
elseif b4>126 then
	goto main1
endif
poke b4,sd
inc b4
serout tso,t4800,(sd)
goto main1

readcommand:
serout ts0,t4800,(ent)
pause 1

peek 80,sd
select sd
case "b","B"
	peek 81,sd
	select sd
	case "k","K"
		peek 82,sd
		select sd
		case "s","S"
			peek 83,sd
			select sd
			case "p","P"
				b5=83
				do
				inc b5
				peek b5,sd
				if sd=0 then
					b0=1
					goto set1
				endif
				loop until sd>47 and sd<58
				gosub numb0
				
				set1:
				b1=0
				'gosub datab1
				for b6=1 to b0
				gosub statchk
				'low wr,ce
				high portc 7,6,1
				low portc 5,4,3,2,0
				pauseus 100
				'high ce,wr
				pauseus 50
				dirsc=0
				next b6
				
				gosub statchk
				'low wr,ce
				high portc 7,6,2
				low portc 5,4,3,1,0
				pauseus 100
				'high ce,wr
				pauseus 50
				dirsc=0
			else
				goto invalid1
			endselect
		else
			goto invalid1
		endselect
	else
		goto invalid1
	endselect	
case "c","C"
	peek 81,sd
	select sd
	case "a","A"
		b5=82
		gosub numb0
		if b0>131 then invalid3
		b1=b0 and %00001111
		gosub wrcomb1
		b1=b0 and %11110000 /16 or %00010000
		gosub wrcomb1
	case "l","L"
		peek 82,sd
		select sd
		case "r","R"
			peek 83,sd
			select sd
			case "t","T"
				peek 84,sd
				select sd
				case "s","S"
					serout ts0,t4800,(clr)
				else
					goto invalid1
				endselect
			else
				goto invalid1
			endselect
		else
			goto invalid1
		endselect
	else
		goto invalid1
	endselect
case "d","D"
	peek 81,sd
	select sd
	case "s","S"
		peek 82,sd
		select sd
		case "p","P"
			peek 83,sd
			select sd
			case " "
				peek 84,sd
				select sd
				case "o","O"
					peek 85,sd
					select sd
					case "f","F"
						b1=%10101110
					case "n","N"
						b1=%10101111
					else
						goto invalid1
					endselect
					gosub wrcomb1
				else
					goto invalid1
				endselect
			else
				goto invalid1
			endselect
		else
			goto invalid1
		endselect
	else
		goto invalid1
	endselect
case "l","L"
	peek 81,sd
	select sd
	case "a","A"
		j_la:
		b5=82
		gosub numb0
		if b0>63 then invalid3
		b1=b0 and %00111111 or %01000000
		gosub wrcomb1
	else
		goto invalid1
	endselect
case "r","R"
	peek 81,sd
	select sd
	case "a","A"
		goto j_la
	case "d","D"
		peek 82,sd
		select sd
		case "a","A"
			peek 83,sd
			select sd
			case "s","S"
				peek 84,sd
				select sd
				case "c","C"
					peek 85,sd
					select sd
					case "i","I"
						for b5=0 to 255
						serout tso,t4800,(#b5,"= ",b5,ent)
						if b5=50 or b5=100 or b5=150 or b5=200 then
							pause 2
							serout tso,t4800,("press any key to continue",ent)
							serin tsi,t4800,sd
						elseif b5=11 then
							pause 2
							serout tso,t4800,("12 clears the whole of this display window",ent)
							b5=12
						endif
						pause 2
						next b5
					else
						goto invalid1
					endselect
				else
					goto invalid1
				endselect
			else
				goto invalid1
			endselect
		else
			goto invalid1
		endselect
	else
		goto invalid1
	endselect
case "w","W"
	peek 81,sd
	select sd
	case "r","R"
		peek 82,sd
		select sd
		case "b","B"
			b5=82
			do
			b0=0
			gosub bin8
			if b0=0 and sd=0 then exit
			gosub wrdatab0
			loop until b5>126 or sd=0
		case "d","D"
			b5=83
			do
			peek b5,sd
			select sd
			case 0
				goto out3
			case spmk
				
			case 48 to 57
				gosub numb0
				gosub wrdatab0
			endselect
			inc b5
			loop until b5>126
			out3:
		case "s","S"
			peek 83,sd
			select sd
			case "c","C"
				peek 84,sd
				select sd
				case "n","N"
					b0=0
					'gosub datab0
			
					'gosub adpc
					
					for b0=0 to 255
					gosub wrdatab0
					next b0
				else
					goto invalid1
				endselect
			else
				goto invalid1
			endselect
		case "t","T"
			b5=83
			do
			inc b5
			peek b5,b0
			if b0=0 then exit
			b0=b0-32
			gosub wrdatab0
			
			loop until b5>126
		else
			goto invalid1
		endselect
	else
		goto invalid1
	endselect

case 0
else
	goto invalid1
endselect
goto main

invalid1:
serout tso,t4800,("The text entered is not recognised as a valid command.",ent)
pause 2
goto main

invalid2:
serout tso,t4800,("The typed command doesn't have the correct parameters.",ent)
pause 2
goto main

end

statchk:
low a0
pauseus 10
low rd
pause 1
hspiin (b2)
high rd
if hres=1 then rstcond
if busy=1 then statchk
serout tso,t4800,("column adrs. ")
pause 1
if adc=1 then
	serout tso,t4800,("reversed; ")
else
	serout tso,t4800,("normal; ")
endif
pause 1
serout tso,t4800,("display ")
pause 1
if donf=1 then 
	serout tso,t4800,("off",ent)
else
	serout tso,t4800,("on",ent)
endif
return

rstcond:
inc b12
serout tso,t4800,("reset condition",ent)
pause 400
if b12<12 then goto statchk
serout tso,t4800,("timeout.",ent)


wrdatab0:
gosub statchk
high a0
pauseus 20
low wr
hspiout (b0)
pauseus 5
high wr
pauseus 5
low a0
return

wrdatab1:
gosub statchk
high a0
pauseus 20
low wr
hspiout (b1)
pauseus 5
high wr
pauseus 5
low a0
return

wrcomb1:
gosub statchk
low wr
hspiout (b1)
pauseus 5
high wr
return


numb0:
inc b5
peek b5,b6
select b6
case 48 to 57'0-9
	inc b5
	peek b5,b7
	select b7
	case 48 to 57'0-9
		inc b5
		peek b5,b8
		select b8
		case 48 to 57'0-9
			goto invalid3
		else
			dec b5
			if sd>50 then invalid3
			if sd=50 then
				select b6
				case >53
					goto invalid3
				case 53
					if b7>53 then invalid3
				endselect
			endif
			b9=b6-48*10
			b10=b7-48
			b0=sd-48*100+b9+b10
		endselect
	else
		dec b5
		b0=sd-48*10+b6-48
		endselect
else
	dec b5
	b0=sd-48
endselect
return

invalid3:
serout tso,t4800,("number too large",ent)
b0=0
return

bin8:
do
inc b5
peek b5,sd
if b5>126 or sd=0 then return endif
loop until sd=48 or sd=49
select sd
case 48
	bit7=0
case 49
	bit7=1
else
	b0=0
	serout tso,t4800,("system error",ent)
	return
endselect

inc b5
peek b5,sd
select sd
case 48
	bit6=0
case 49
	bit6=1
else
	b0=b0/128
	return
endselect

inc b5
peek b5,sd
select sd
case 48
	bit5=0
case 49
	bit5=1
else
	b0=b0/64
	return
endselect

inc b5
peek b5,sd
bin5:
select sd
case 48
	bit4=0
case 49
	bit4=1
else
	b0=b0/32
	return
endselect

inc b5
peek b5,sd
select sd
case 48
	bit3=0
case 49
	bit3=1
else
	b0=b0/16
	return
endselect

inc b5
peek b5,sd
select sd
case 48
	bit2=0
case 49
	bit2=1
else
	b0=b0/8
	return
endselect
					
inc b5
peek b5,sd
select sd
case 48
	bit1=0
case 49
	bit1=1
else
	b0=b0/4
	return
endselect

inc b5
peek b5,sd
select sd
case 48
	bit0=0
case 49
	bit0=1
else
	b0=b0/2
	return
endselect
return
no replies recently.
 

Attachments

Last edited:

tiscando

Senior Member
about X1.

[For the underlying problem, please see last post]

It seems that I just simply can't write long programs for the X1 parts without encountering those invisible problems, which possibly mean faults in the 'axevsm1.dll'.

Here is another example of the above: (too long-winded for thorough testing in PE's simul.; 40x1 used)

see the program in the post after this one (because it is too long to paste it in the post text.)

N.S.L.= "no source line at pc address"
every ; means "then after (another) click on the step in button: "

The picaxe connected to the graphical lcd would write "USER" to the lcd. (It is going to display "USER NET", but I haven't 'carved' in the "NET" under "USER" in the 'lookup' data yet.)
I step through the program in the code window. As it enters a 'gosub stat01', the window greys out, saying
N.S.L. [pc=5614];
[pc=5621];
[pc=5656];
[pc=5663];
then returns under the gosub.
I think it did the sub properly, but I get lost and can't see what it is doing. same for all other 'gosub stat01's before address $4000.

This means that sub-procedures fully beyond address $4000 don't step through normally, and most of the time, the code window does not show the code, but a 'no source line' message. While in this, the sub-procedure code usually does execute, but possibly not mostly how it's written.
The first time I get to see the code after this is usually when it returns from the sub-procedure, and back to the main code that is before address $4000 (under the triggered gosub command).


Next, the pointer steps to the 'select... case...:let...:lookup... ' lines, and after the top one (as if w3<16), it says
N.S.L.[pc=54C3];
[pc=5669];
[pc=5676] when out6=0;
[pc=56B0];
[pc=56BD] when out6=1;
[pc=56C7];
[pc=56D4] when out7=0;
[pc=56E7] when portc becomes outputs;
[pc=56F6] when portc = b0;
[pc=570A] when the written byte gets displayed on the LCD;
[pc=5717];
[pc=5724] when out7=1;
[pc=5730] when portc becomes inputs;
[pc=54E0];
And then goes back to the first 'select... case...:let...:lookup... ' line.
Although it works, I just can't see the code:confused:.

Next, the true problem. See the image below,
I saw something strange on the LCD. I investigated by putting breakpoints on the lookup commands, and found that it is at the 'case <800 : let b4=w3-784 : lookup...' at address $4004. As the breakpoint is triggered, when I click the step button on the code window, the picaxe resets (not properly), as suggested by the error log. This happens instead of completing filling the rest of the data to the lcd, and then terminating.:(

The extra %00010000,%00010000 on the LCD during the initialisation code is possibly because the GLCD is in fast write mode.

Sequence at:
pointer at $4004 {case <800 : let b4=w3-784 : lookup b4, (...16 bytes...),b0};
PortC becomes outputs except C.2;
$0017 {pins=%11111001} All variables are reset (but pin states stay the same);
$002F {setfreq m8} pin4=1;
Continues like first run (although portC is outputs until the next 'dirsc=0', which caused a logic contention.


Code at 'endselect' beyond with the addresses as seen in the picaxe VSM code debug window:
Code:
---- endselect
---- 
44F7 gosub autodatab0
4505 next w3
450C low rd
---- do
452C if portc pin3=1 then exit
4533 loop
453A high rd
4553 pauseus 1
456C low portc 6,3,2,0 'auto reset
45B3 high portc 7,5,4,1
4627 pulsout wr,5
4638 high ce
4649 dirsc=0
4657 end
----
---- '-----------Sub-Procedurs-----------'
---- stat01:
465E low rd
467E if portc pin0=0 or pin1=0 then stat01
4685 high rd
468C return
----
---- autodatab0:
46A5 low rd
---- do
46BE if portc pin3=1 then exit'loop until portc pin3=1' is not supported.
46DE loop
46E5 high rd
46EC pauseus 1
4705 low cd
471E let dirsc=%11111111
4747 let pinsc=b0
476C pulsout wr,5
4779 pauseus 2
478A high cd
479B dirsc=0
47A9 return
 

Attachments

Last edited:

tiscando

Senior Member
Here's the attached program for the upper thread.

edit: If I remove the setfreq m8, the display writing speed stays the same, and as the code writes the last byte of 'case <784 : let b4=w3-768 : lookup ...', the error log pops up saying access violation in module 'axevsm1.dll'.
 

Attachments

Last edited:

Technical

Technical Support
Staff member
As stated in post #13 we will look into the suspected 'select case' bug in the next release. Until then you should not use 'select case' in any simulated program.
 

tiscando

Senior Member
Thanks, so if I use select...case, then all those mad problems occur in parts of the program. I will work around this for now. I never knew that until now, or is it exactly?
 
Last edited:

tiscando

Senior Member
...or is it exactly?
-No.

Even when I have not included any 'select...case...endselect' in the faulty program, I encountered yet another of those invisible errors. [update: this is underlined in the last post]

See the attachments: in the simulation, I press the 'chs/lba' button on the keypad, in U1's program, it goes down to the return command
in the 'chslba' sub, goes back to the on...gosub, and then rather than going to the line under the on...gosub, it goes to the 'erronce' sub.
it is in a constant loop between the 'chslba' and 'erronce' sub, also going into 'masterslave' as well. When I click the run button, the glcd
displays words that keep changing, until the error log pops up saying 'stack overflow'.


atahdd debug1.bas (U1)
Code:
symbol iocs16=pin0'porta
symbol dmarq=pin1

symbol sel=3'outputs
symbol tso=4
symbol gso=5
symbol dw=6
symbol dr=7

symbol irdy=pin0'inputs
symbol intrq=pin2
symbol pdiag=pin5
symbol dasp=pin6
symbol cts=pin7
symbol sri=4
symbol gsi=7
symbol tsi=3

symbol ordy=0'portc
symbol dmack=1

symbol cs=bit16'b2 is used as a bit register
symbol cs1=0
symbol cs3=1
symbol adm=bit17
symbol chs=0
symbol lba=1
symbol mrsl=bit18
symbol master=0
symbol slave=1
symbol hdb0=bit19
symbol hexbin0=1
symbol ofdec0=0
symbol hdb1=bit20
symbol decbin1=1
symbol ofhex1=0
symbol eret=bit21
symbol norm=0
symbol once=1


symbol ent=$0d

symbol rprtc=%00000010'the RS232 40x1 IO expanders
symbol wprtc=%00000011
symbol wdirc=%00000101
symbol rin=%00000110
symbol wout=%00000111
symbol rpa=%00100010
symbol rmem=%00100010
symbol wmem=%00100011
'xx001xxx=readadc
'xx010xxx=clear outpin
'xx011xxx=set outpin
symbol kpscan=%00110000

symbol hics1=%00011111
symbol locs1=%00010111
symbol hics3=%00011110
symbol locs3=%00010110
symbol hirst=%00011101
symbol lorst=%00010101

symbol ch8line1=0
symbol ch8line2=16
symbol ch8line3=32
symbol ch8line4=48
symbol ch8line5=64
symbol ch8line6=80
symbol ch8line7=96
symbol ch8line8=112
symbol ch6line1=0
symbol ch6line2=21
symbol ch6line3=42
symbol ch6line4=63
symbol ch6line5=84
symbol ch6line6=105
symbol ch6line7=126
symbol ch6line8=147

symbol lch6line1=1
symbol lch6line2=22
symbol lch6line3=43
symbol lch6line4=64
symbol lch6line5=85
symbol lch6line6=106
symbol lch6line7=127
symbol lch6line8=148


symbol kidentdev=20'keypad part of io expander 0
symbol kwrtcatche=21
symbol krdlkahead=22
symbol kpwronrevers=23
symbol kverify=24
symbol kseek=25
symbol kdevdiag=26
symbol kmultimode=27
symbol krecalib=28
symbol ksecadres=29
symbol kreadsec=30
symbol kwritesec=31
'1 to 15 = k1 to kF
symbol k0=16
symbol kyes=17
symbol kno=18
symbol khexbin=19
symbol kbksp=32
symbol kblank1=33
symbol kchslba=34
symbol konce=35
symbol kmrsl=36

symbol gwrtxt		=%11111111'commands for graphical lcd interface
symbol gwrend		=%11111110
symbol gnormal		=%00000100
symbol gonce		=%00000101
symbol gmulti		=%00000110
symbol ghdboff		=%00001000
symbol ghex		=%00001001
symbol gdec		=%00001010
symbol gbin		=%00001011
symbol gsecno		=%00001100
symbol gcyllow		=%00001101
symbol gcylhigh	=%00001110
symbol gchlbmrsl	=%00010000
symbol gclrtxt		=%00011000
symbol glistptr	=%00100000
symbol ghdsel		=%00110000


symbol srst=bit2'device control
symbol nien=bit1

symbol bbk=bit7'error register
symbol unc=bit6
symbol mc=bit5
symbol idnf=bit4
symbol mcr=bit3
symbol abrt=bit2
symbol tk0nf=bit1
symbol amnf=bit0

symbol bsy=bit7'status register
symbol drdy=bit6
symbol dwf=bit5
symbol dsc=bit4
symbol drq=bit3
symbol corr=bit2
symbol idx=bit1
symbol err=bit0

init:
setfreq m8
pins=%11011000
high portc dmack
high sel
sertxd (hics1)
pause 1
sertxd (hics3)
pause 5
sertxd (hirst)

main:
pause 1
low sel
sertxd (kpscan)
serin sri,n4800,b3
if b3<19 then main
b3=b3-19
on b3 gosub hexdecbin,identifydevice,writecatche,readlkahead,pwronreversion,verify,seek,devicediag,multimode,recalibrate,sectoradres,readsectors,writesectors,main,main,chslba,erronce,masterslave
goto main



'-----atahdd command subs-----'
hexdecbin:
if hdb0=hexbin0 then
	if hdb1=ofhex1 then
		hdb0=ofdec0
		hdb1=decbin1
	else
		hdb1=ofhex1
	endif
else
	if hdb1=decbin1 then
		hdb0=hexbin0
	else
		hdb0=hexbin0
		hdb1=ofhex1
	endif
endif
b0=ghdboff
bit0=hdb0
bit1=hdb1
do
loop until cts=1
serout gso,n4800,(b0)
return


identifydevice:

return


writecatche:

return


readlkahead:

return


pwronreversion:

return


verify:

return


seek:

return


devicediag:

return


multimode:

return


recalibrate:
gosub statwait
high 0,1,2'command
b0=$10'recalibrate
b1=0
cs=cs3
gosub wdata

gosub statwait
serout tso,n4800, ("Recalibrated.",ent)
return


sectoradres:

return


readsectors:


gosub statwait
high 0,1,2'command
if eret=once then
	b0=$21'read sectors once
else
	b0=$20'read sectors
endif
b1=0
cs=cs3
gosub wdata

gosub statwait
serout tso,n4800, ("Sectors read.",ent)
return


writesectors:

return


chslba:
b0=gchlbmrsl
if mrsl=master then let bit0=master else bit0=slave endif
if adm=chs then
	adm=lba
	bit1=lba
else
	adm=chs
	bit1=chs
endif
do
loop until cts=1
serout gso,n4800,(b0)	
return


erronce:
do
loop until cts=1
if eret=norm then
	eret=once
	serout gso,t4800,(gonce)
else
	eret=norm
	serout gso,t4800,(gnormal)
endif
return


masterslave:
b0=gchlbmrsl
if adm=chs then let bit1=chs else bit1=lba endif
if adm=master then
	mrsl=slave
	bit0=slave
else
	mrsl=master
	bit0=master
endif
do
loop until cts=1
serout gso,n4800,(b0)	
return



'-----other sub-procedurs-----'
error1:
cs=cs3
low 1,2
high 0
gosub rdata
if bbk=1 then sertxd ("Bad block/sector detected.",ent) endif
if unc=1 then sertxd ("Data error/corruption.",ent) endif
if mc=1 then sertxd ("Media is changed.",ent) endif
if idnf=1 then sertxd ("ID not found.",ent) endif
if mcr=1 then sertxd ("Media change requested.",ent) endif
if abrt=1 then sertxd ("This command has been aborted.",ent) endif
if tk0nf=1 then sertxd ("Track 0 not found.",ent) endif
if amnf=1 then sertxd ("Address mark not found.",ent) endif
return


wdata:
gosub cssel

low sel
sertxd (wdirc)
pause 1
sertxd (%11111111)
pause 1

high sel
sertxd (wdirc)
pause 1
sertxd (%11111111)
pause 1

low sel
sertxd (wprtc)
pause 1
sertxd (b0)
pause 1

high sel
sertxd (wprtc)
pause 1
sertxd (b1)

high dw
pulsout dw,100

low sel
sertxd (wdirc)
pause 1
sertxd (%00000000)
pause 1

high sel
sertxd (wdirc)
pause 1
sertxd (%00000000)
return


rdata:
gosub cssel

low sel
sertxd (wdirc)
pause 1
sertxd (%00000000)
pause 1

high sel
sertxd (wdirc)
pause 1
sertxd (%00000000)
pause 1

low dr
pause 1

low sel
sertxd (rprtc)
serin sri,n4800,b0
pause 1

high sel
sertxd (rprtc)
serin sri,n4800,b1

high dr
return


cssel:
high sel
if cs=cs3 then
	sertxd (hics1)
	pause 1
	sertxd (locs3)
else
	sertxd (locs1)
	pause 1
	sertxd (hics3)
endif
pause 1
return


statwait:
high 0,1,2
cs=cs3
gosub rdata
if bsy=1 then statwait
if drdy=0 and err=0 and drq=0 then statwait
if err=1 then error1
return
 

Attachments

Last edited:

tiscando

Senior Member
here are the other 2 programs for the above post.

rs232 40x1 expanders.bas (U3)
Code:
symbol tout=2'ms
symbol sri=0
symbol sel1=pin1
symbol id=0	'valid number: 0 to 1
setfreq m8

start:
serin sri,n4800,b3
if sel1<>id then start
if b3=%00000010 then	'read portc
	gosub readprtc0
	sertxd (b0)
elseif b3=%00000011 then	'write portc
	serin [tout,start],sri,n4800,b2
	if sel1<>id then start
	pinsc=b2
elseif b3=%00000101 then	'write dirsc
	serin [tout,start],sri,n4800,b2
	if sel1<>id then start
	dirsc=b2
elseif b3=%00000110 then	'read inputs
	sertxd (pins)
elseif b3=%00000111 then	'write to outputs
	serin [tout,start],sri,n4800,outpins
	if sel1<>id then start
elseif b3=%00100000 then	'read porta
	gosub readpa0
	sertxd (b0)
elseif b3=%00100010 then	'read eeprom
	serin [tout,start],sri,n4800,b2
	if sel1<>id then start
	read b2,b0
	sertxd (b0)
elseif b3=%00100011 then	'write eeprom
	serin [tout,start],sri,n4800,b2,b0
	if sel1<>id then start
	write b2,b0
elseif b3=%00110000 then	'scan keypad
	gosub kploop
	
else
	b2=b3 and %11111000
	b0=b3 and %00000111
	if b2=%00001000 then'read adc
		readadc b0,b4
		sertxd (b4)
	elseif b2=%00010000 then'clear outpin
		low b0
	elseif b2=%00011000 then'set outpin
		high b0
	endif
endif
goto start


readpa0:
b0=0
if porta pin0=1 then let bit0=1 endif
if porta pin1=1 then let bit1=1 endif
if porta pin2=1 then let bit2=1 endif
if porta pin3=1 then let bit3=1 endif
return

readprtc0:
b0=0
if portc pin0=1 then let bit0=1 endif
if portc pin1=1 then let bit1=1 endif
if portc pin2=1 then let bit2=1 endif
if portc pin3=1 then let bit3=1 endif
if portc pin4=1 then let bit4=1 endif
if portc pin5=1 then let bit5=1 endif
if portc pin6=1 then let bit6=1 endif
if portc pin7=1 then let bit7=1 endif
return



kploop:
high 0,1,2,3
if porta pin0=1 then	'1
	low 1,2,3
	high 0
	if porta pin0=1 then	'A: Identify device [b]
		b4=20
	else
		low 0,2,3
		high 1
		if porta pin0=1 then	'B: write cache [o]
			b4=21
		else
			low 0,1,3
			high 2
			if porta pin0=1 then	'C: Read lookahead [o]
				b4=22
			else
				low 0,1,2
				high 3
				if porta pin0=1 then	'D:Power-on revers. [o]
					b4=23
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif porta pin1=1 then	'2
	low 1,2,3
	high 0
	if porta pin1=1 then	'Verify [b]
		b4=24
	else
		low 0,2,3
		high 1
		if porta pin1=1 then	'Seek [b]
			b4=25
		else
			low 0,1,3
			high 2
			if porta pin1=1 then	'Device diagnostic [b]
				b4=26
			else
				low 0,1,2
				high 3
				if porta pin1=1 then	'Multiple mode [b]
					b4=27
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif porta pin2=1 then	'3
	low 1,2,3
	high 0
	if porta pin2=1 then 	'Recalibrate [b]
		b4=28
	else
		low 0,2,3
		high 1
		if porta pin2=1 then	'Sector address [o]
			b4=29
		else
			low 0,1,3
			high 2
			if porta pin2=1 then	'Read sector [g]
				b4=30
			else
				low 0,1,2
				high 3
				if porta pin2=1 then	'Write sector [r]
					b4=31
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif porta pin3=1 then	'4
	low 1,2,3
	high 0
	if porta pin3=1 then 	'7 [w]
		b4=7
	else
		low 0,2,3
		high 1
		if porta pin3=1 then	'4 [w]
			b4=4
		else
			low 0,1,3
			high 2
			if porta pin3=1 then	'1 [w]
				b4=1
			else
				low 0,1,2
				high 3
				if porta pin3=1 then	'0 [w]
					b4=16
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif pin4=1 then		'5
	low 1,2,3
	high 0
	if pin4=1 then	'8 [w]
		b4=8
	else
		low 0,2,3
		high 1
		if pin4=1 then	'5 [w]
			b4=5
		else
			low 0,1,3
			high 2
			if pin4=1 then	'2 [w]
				b4=2
			else
				low 0,1,2
				high 3
				if pin4=1 then	'yes/enter [o]
					b4=17
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif pin5=1 then		'6
	low 1,2,3
	high 0
	if pin5=1 then	'9 [w]
		b4=9
	else
		low 0,2,3
		high 1
		if pin5=1 then	'6 [w]
			b4=6
		else
			low 0,1,3
			high 2
			if pin5=1 then	'3 [w]
				b4=3
			else
				low 0,1,2
				high 3
				if pin5=1 then	'no/back [o]
					b4=18
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif pin6=1 then		'7
	low 1,2,3
	high 0
	if pin6=1 then	'A [w]
		b4=10
	else
		low 0,2,3
		high 1
		if pin6=1 then	'C [w]
			b4=12
		else
			low 0,1,3
			high 2
			if pin6=1 then	'E [w]
				b4=14
			else
				low 0,1,2
				high 3
				if pin6=1 then	'blank1 [w]
					b4=33
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif pin7=1 then		'8
	low 1,2,3
	high 0
	if pin7=1 then 'B [w]
		b4=11
	else
		low 0,2,3
		high 1
		if pin7=1 then	'D [w]
			b4=13
		else
			low 0,1,3
			high 2
			if pin7=1 then	'F [w]
				b4=15
			else
				low 0,1,2
				high 3
				if pin7=1 then	'once [o]
					b4=35
				else
					goto kploop
				endif
			endif
		endif
	endif
elseif pin3=1 then		'8
	low 1,2,3
	high 0
	if pin3=1 then 'Backspace [w]
		b4=11
	else
		low 0,2,3
		high 1
		if pin3=1 then	'hex/dec/binary [o]
			b4=19
		else
			low 0,1,3
			high 2
			if pin3=1 then	'CHS/LBA [o]
				b4=34
			else
				low 0,1,2
				high 3
				if pin3=1 then	'master/slave [o]
					b4=36
				else
					goto kploop
				endif
			endif
		endif
	endif
else
	goto kploop
endif

sertxd (b4)
return
rs232 40x1 expander id1.bas (U2)
Code:
symbol tout=2'ms
symbol sri=0
symbol sel1=pin1
symbol id=1	'valid number: 0 to 1
setfreq m8

start:
serin sri,n4800,b3
if sel1<>id then start
select b3
case %00000010			'read portc
	gosub readprtc0
	sertxd (b0)
case %00000011			'write portc
	serin [tout,start],sri,n4800,b2
	if sel1<>id then start
	pinsc=b2
case %00000101			'write dirsc
	serin [tout,start],sri,n4800,b2
	if sel1<>id then start
	dirsc=b2
case %00000110			'read inputs
	sertxd (pins)
case %00000111			'write to outputs
	serin [tout,start],sri,n4800,outpins
	if sel1<>id then start
case %00100000			'read porta
	gosub readpa0
	sertxd (b0)
case %00100010			'read eeprom
	serin [tout,start],sri,n4800,b2
	if sel1<>id then start
	read b2,b0
	sertxd (b0)
case %00100011			'write eeprom
	serin [tout,start],sri,n4800,b2,b0
	if sel1<>id then start
	write b2,b0
else
	b2=b3 and %11111000
	b0=b3 and %00000111
	if b2=%00001000 then'read adc
		readadc b0,b4
		sertxd (b4)
	elseif b2=%00010000 then'clear outpin
		low b0
	elseif b2=%00011000 then'set outpin
		high b0
	endif
endselect
goto start


readpa0:
b0=0
if porta pin0=1 then let bit0=1 endif
if porta pin1=1 then let bit1=1 endif
if porta pin2=1 then let bit2=1 endif
if porta pin3=1 then let bit3=1 endif
return

readprtc0:
b0=0
if portc pin0=1 then let bit0=1 endif
if portc pin1=1 then let bit1=1 endif
if portc pin2=1 then let bit2=1 endif
if portc pin3=1 then let bit3=1 endif
if portc pin4=1 then let bit4=1 endif
if portc pin5=1 then let bit5=1 endif
if portc pin6=1 then let bit6=1 endif
if portc pin7=1 then let bit7=1 endif
return
 

Technical

Technical Support
Staff member
tiscando - we sent you a PM a few days back asking whether you wanted to beta test the new version, which will resolve these issues. Please check your PM.
 

tiscando

Senior Member
Thanks very much for repairing many issues, including adding colour syntax to the picaxe programs:D

although, after I installed the new vsm version, 1.0.4, I got a new error to do with the keypad in the design posted above in posts #23 and #24.
the keypad's column pins are tied low. U3 swiches outputs 0 to 3 high. when outs 0, 1, and 2 are high, the keypad columns 1 to 8 become floating. when all 4 are high, the columns 1 to 8 become high. column 9 remains low.
I changed the resistor array for seperate resistors, and it works ok now.
after this, the older problems have gone away now.:)
 
Last edited:

tiscando

Senior Member
Erm, I'm possibly not completely satisfied yet...

I still get the 'jumpy simulation' problem as stated in post #11 part !. To recall it, the pointer enters 'high 7,6,5,4,3,2,1,0', turns pin7 high, the pointer goes to the top of the program when it shouldn't do, turns the other pins high, and then the pointer goes to the line under this command.

Next, I have just encountered yet another uncertainity problem as follows:
I press the 'hex/dec/binary' button on the keypad.
In the full program, the pointer goes to the first 'gosub tp2hexb0' under the label 'uchs:', and in the bank of ifs. then the pointer jumps straight into 'else' under 'tp2hexb0:', then goes on:
b8=b8-10 ~ nothing
lookup b8,("ABCDEF"),b1 ~ b1 becomes 16
b1=b1-32 ~ nothing
~ jumps to
b8=b0 and %00001111 ~ executes sub 'datab1:' (correctly)
if b8<10 then ~ b1 becomes 192
b1=b8+16 ~ executes sub 'comb1:'
else
b8=b8-10 ~ nothing
lookup b8,("ABCDEF"),b1 ~ b1 becomes 16
b1=b1-32 ~ nothing
~ jumps to
return ~ executes sub 'datab1:'
~ under 'bin8:'
b1=autowrite ~ b1 becomes 192
gosub comb1 ~ executes sub 'comb1:'
b1=16 ~ returns

Then,
b0=cyllow ~ sets outpin3 low instead.
gosub tp2hexb0 ~ the second one; this time,
~ outpin 2 goes low,
~ and it gets stuck there. When I click the run button, I get 'axevsm error' in the error log.


I have just cut out the unused parts of the program when testing this 'ghex' route (where the program branches on the first time I click the hex/dec/binary button), and the problem isn't there. here is the resulting program without the problem showing. If I add the other parts onto it, the problem returns.:confused:

glcdfhdd debug.bas:
Code:
symbol cd=7 'command/status, not data
symbol rd=6 'not read enable
symbol wr=5 'not write enable
symbol ce=4 'not chip enable
symbol rst=3'not chip reset
symbol fs1=2'0= 8 bits per seg, 1= 6
symbol cts=0

symbol sri=0

symbol tout=10

symbol adp=b26
symbol secno=b9
symbol cyllow=b10
symbol cylhigh=b11
symbol hdsel=b12

symbol adm=bit18'b2 is used as a bit register.
symbol chs=0
symbol lba=1
symbol hdb0=bit16
symbol hexbin0=1
symbol ofdec0=0
symbol hdb1=bit17
symbol decbin1=1
symbol ofhex1=0
symbol uln4=bit20
symbol uln5=bit21
symbol uln6=bit22
symbol uln7=bit23

symbol master=0
symbol slave=1

symbol vmrsl=bit24
symbol vadm=bit25

symbol cursptr		=%00100001'commands for T6963C
symbol cgramoffset	=%00100010
symbol adresptr	=%00100100
symbol texthomadres	=%01000000
symbol textarea	=%01000001
symbol grphomadres	=%01000010
symbol grpharea	=%01000011
symbol autoread	=%10110001
symbol autowrite	=%10110000
symbol autoreset	=%10110010
symbol writeincadp	=%11000000
symbol readincadp	=%11000001
symbol writedecadp	=%11000010
symbol readdecadp	=%11000011
symbol writenvadp	=%11000100
symbol readnvadp	=%11000101

symbol ch6line1=0
symbol ch6line2=21
symbol ch6line3=42
symbol ch6line4=63
symbol ch6line5=84
symbol ch6line6=105
symbol ch6line7=126
symbol ch6line8=147

symbol hdbpos=7
symbol eretpos=0
symbol admpos=11
symbol mrslpos=15


setfreq m8
pins=%11111000

gosub setch6
b1=%10010100
gosub comb1
main:
b3=%00001001
on b3 gosub x,x,x,x,x,x,x,x,x,ghex,x,x,x,x,x
x:         '0000   ,0100   ,0101 ,0110    ,1000   ,1001,1010,1011,1100  ,1101   ,1110
goto main


ghex:
w0=ch6line8+hdbpos
gosub adpcw0

b1=autowrite
gosub comb1
for b4=0 to 3
lookup b4,("Hex "),b0
b0=b0-32
gosub audatab0
next b4
b1=autoreset
gosub comb1

hdb0=hexbin0
hdb1=ofhex1
gosub update
return


'**********-----other sub-procedurs-----**********

audatab0:
low ce
for b13=0 to 255
low rd
if portc pin3=1 then dskip0
next b13
gosub rautowrite
goto audatab0

datab0:
low rd,ce
if portc pin0=0 or pin1=0 then datab0
high rd
dskip0:
high rd
low cd
dirsc=%11111111
pinsc=b0
pulsout wr,5
pauseus 2
high cd
dirsc=0
high ce
return

audatab1:
low ce
for b13=0 to 255
low rd
if portc pin3=1 then dskip1
next b13
gosub rautowrite
goto audatab1

datab1:
low rd,ce
if portc pin0=0 or pin1=0 then datab1
high rd
dskip1:
high rd
low cd
dirsc=%11111111
pinsc=b1
pulsout wr,5
pauseus 2
high cd
dirsc=0
high ce
return

rautowrite:
low rd
if portc pin0=0 or pin1=0 then rautowrite
high rd
dirsc=%11111111
pinsc=autowrite
pulsout wr,5
pauseus 2
dirsc=0
return

comb1:
low rd,ce
if portc pin0=0 or pin1=0 then comb1
high rd
dirsc=%11111111
pinsc=b1
pulsout wr,5
pauseus 2
dirsc=0
high ce
return

adpcw0:
gosub datab0
gosub datab1
b1=adresptr
gosub comb1
return

clrline:
b1=autowrite
gosub comb1
for b4=1 to ch6line2
b0=0
gosub audatab0
next b4
b1=autoreset
gosub comb1

w0=adp
return


setch6:
high fs1

b1=21
gosub datab1
b1=textarea
gosub comb1

b1=21
gosub datab1
b1=textarea
gosub comb1

b1=21
gosub datab1
b1=grpharea
gosub comb1

b1=21
gosub datab1
b1=grpharea
gosub comb1
return


update:'---------------------------------update
if uln4=0 then
	w0=ch6line4
	gosub adpcw0
	gosub clrline
endif
if uln5=0 then
	w0=ch6line5
	gosub adpcw0
	gosub clrline
endif
if uln6=0 then
	w0=ch6line6
	gosub adpcw0
	gosub clrline
endif
if uln7=0 then
	w0=ch6line7
	gosub adpcw0
	gosub clrline
endif

hdsel=hdsel and %00001111
if adm=chs then uchs
if adm=lba then ulba

uchs:
if hdb0=hexbin0 and hdb1=decbin1 then
	w0=ch6line4
	if uln4=1 or uln5=1 or uln6=1 or uln7=1 then return endif
else
	w0=ch6line6
	if uln6=1 or uln7=1 then return endif
endif
gosub adpcw0
b1=autowrite
gosub comb1
for b4=0 to 20
b0=32
lookup b4,("Cylinder:"),b0
b0=b0-32
gosub audatab0
next b4
b1=autoreset
gosub comb1

if hdb0=hexbin0 and hdb1=decbin1 then
	w0=ch6line6
else
	w0=ch6line7
endif
gosub adpcw0
b1=autowrite
gosub comb1
for b4=0 to 20
b0=32
lookup b4,("Sector:      head:"),b0
b0=b0-32
gosub audatab0
next b4
b1=autoreset
gosub comb1

if hdb0=hexbin0 then
	if hdb1=ofhex1 then	'hex
		w0=ch6line6+10
		gosub adpcw0
		b0=cylhigh
		gosub tp2hexb0
		b0=cyllow
		gosub tp2hexb0
		
		w0=ch6line7+8
		gosub adpcw0
		b0=secno
		gosub tp2hexb0
		
		w0=ch6line7+19
		gosub adpcw0
		b0=hdsel
		if b0<10 then
			b1=b8+16
		else
			b8=b8-10
			lookup b8,("ABCDEF"),b1
			b1=b1-32
		endif
		gosub datab1
		b1=writeincadp
		gosub comb1
	else				'binary
		w0=ch6line5
		gosub adpcw0
		b0=cylhigh
		gosub bin8
		b0=cyllow
		gosub bin8
		
		w0=ch6line7
		gosub adpcw0
		b0=secno
		gosub bin8
		
		w0=ch6line7+13
		gosub adpcw0
		b0=hdsel
		b1=autowrite
		gosub comb1
		gosub bin4
	endif
else'ofdec0
	w0=ch6line6+10
	gosub adpcw0
	b0=cylhigh
	b1=cyllow
	gosub asciidecw0
	
	w0=ch6line7+8
	gosub adpcw0
	b0=secno
	gosub asciidecb0
	
	w0=ch6line7+19
	gosub adpcw0
	b0=hdsel
	bintoascii b0,b16,b15,b14
	if b15="0" then let b15=32 endif
	b0=b15-32
	gosub datab0
	gosub comb1
	if b14="0" then let b14=32 endif
	b0=b14-32
	gosub datab0
	gosub comb1
	endif
return	

ulba:
if hdb0=hexbin0 and hdb1=decbin1 then
	w0=ch6line6
	if uln6=1 and uln7=1 then return endif
else
	w0=ch6line7
	if uln7=1 then return endif
endif
gosub adpcw0
b1=autowrite
gosub comb1
for b4=0 to 20
b0=32
lookup b4,("address:"),b0
b0=b0-32
gosub audatab0
next b4
b1=autoreset
gosub comb1

if hdb0=hexbin0 then
	if hdb1=ofhex1 then
		w0=ch6line7+9
		gosub adpcw0
		b0=hdsel
		
		if b0<10 then
			b1=b8+16
		else
			b8=b8-10
			lookup b8,("ABCDEF"),b1
			b1=b1-32
		endif
		gosub datab1
		b1=writeincadp
		gosub comb1
		
		b0=cylhigh
		gosub tp2hexb0
		b0=cyllow
		gosub tp2hexb0
		b0=secno
		gosub tp2hexb0
	elseif hdb1=decbin1 then
		w0=ch6line6+9
		gosub adpcw0
		b0=hdsel
		gosub bin4
		b0=cylhigh
		gosub bin8
		b0=cyllow
		gosub bin8
		b0=secno
		gosub bin8
	endif
else
	w0=ch6line7+9
	gosub adpcw0
	b0="N"-32
	gosub datab0
	b1=writeincadp
	gosub comb1
	b0="/"-32
	gosub datab0
	b1=writeincadp
	gosub comb1
	b0="A"-32
	gosub datab0
	b1=writeincadp
	gosub comb1
endif
return
	
		
tp2hexb0:
b8=b0 and %11110000 /16
if b8<10 then
	b1=b8+16
else
	b8=b8-10
	lookup b8,("ABCDEF"),b1
	b1=b1-32
endif
gosub datab1
b1=writeincadp
gosub comb1
b8=b0 and %00001111
if b8<10 then
	b1=b8+16
else
	b8=b8-10
	lookup b8,("ABCDEF"),b1
	b1=b1-32
endif
gosub datab1
b1=writeincadp
gosub comb1
return


bin8:
b1=autowrite
gosub comb1
b1=16
if bit7=1 then let b1=17 endif
gosub audatab1
b1=16
if bit6=1 then let b1=17 endif
gosub audatab1
b1=16
if bit5=1 then let b1=17 endif
gosub audatab1
b1=16
if bit4=1 then let b1=17 endif
gosub audatab1
bin4:
b1=16
if bit3=1 then let b1=17 endif
gosub audatab1
b1=16
if bit2=1 then let b1=17 endif
gosub audatab1
b1=16
if bit1=1 then let b1=17 endif
gosub audatab1
b1=16
if bit0=1 then let b1=17 endif
gosub audatab1
b1=autoreset
gosub comb1
return


asciidecw0:
bintoascii w0,b18,b17,b16,b15,b14
if b18="0" then let b18=32 endif
b0=b18-32
gosub datab0
b1=writeincadp
gosub comb1

if b17="0" then let b17=32 endif
b0=b17-32
gosub datab0
gosub comb1

if b16="0" then let b16=32 endif
b0=b16-32
gosub datab0
gosub comb1

if b15="0" then let b15=32 endif
b0=b15-32
gosub datab0
gosub comb1

if b14="0" then let b14=32 endif
b0=b14-32
gosub datab0
gosub comb1
return

asciidecb0:
bintoascii b0,b16,b15,b14
if b16="0" then let b16=32 endif
b0=b16-32
gosub datab0
b1=writeincadp
gosub comb1

if b15="0" then let b15=32 endif
b0=b15-32
gosub datab0
gosub comb1

if b14="0" then let b14=32 endif
b0=b14-32
gosub datab0
gosub comb1
return
What should I do?
 

Technical

Technical Support
Staff member
Sorry your programs and cicruits are so complicated we just can't understand what you mean! Please give a clear concise circuit and program that highlights the error.
 

tiscando

Senior Member
But in this instance, when I give a clear consice circuit and program that highlights the error, the error is not in the clear and concise program, but still in the original program and circuit that is not clear and conscise.
Is it because I run many picaxe X1s in the same schematic?

What should I do about an error that is not a command problem, but is a program flow fault?
With a problem about program flow which doesn't stay on the expected track in the debug window and/or comes up with an axevsm error when on a program branch command like 'goto' and 'gosub', I may have to post in the full circuit and all the programs to do with this circuit.

Next time I report yet another fault of program uncertainity, I will try to provide as much detail about the fault as possible, including a clear timeline that says what is supposed to happen on a command, and what actually happens at the command. I might even try and make a video onto youtube, filming the program flow and where the problem is in the debug window.

When I provide the full program, I thought that the picaxe vsm software makers would download the schematic and programs from the post, and step through it to where I specified where the problem lies, and fix the fault. Because you said:
Sorry your programs and cicruits are so complicated we just can't understand what you mean!
How could I do this so it's understandable, and easy to look at, without making the problem disappear?
 
Last edited:

tiscando

Senior Member
I'll have a try with the table system of reporting program flow faults.

In this code: high all.bas
Code:
[COLOR="Gray"]01[/COLOR] symbol par=b1

[COLOR="Gray"]02[/COLOR] main:
[COLOR="Gray"]03[/COLOR] high 7,6,5,4,3,2,1,0
[COLOR="Gray"]04[/COLOR] goto main
port B is the output port of the 28x1.
Program flow:
Code:
[U]line[/U]                        [U]supposed effect[/U]  [U]actual effect[/U]    [u]should the pointer be on this line?[/u]
03  high 7,6,5,4,3,2,1,0    b.7=H            b.7=H            yes.
01  symbol par=b1           nothing          b.6=H            no, the pointer should be on line 03
01  symbol par=b1           nothing          b.5=H            no, the pointer should be on line 03
01  symbol par=b1           nothing          b.4=H            no, the pointer should be on line 03
01  symbol par=b1           nothing          b.3=H            no, the pointer should be on line 03
01  symbol par=b1           nothing          b.2=H            no, the pointer should be on line 03
01  symbol par=b1           nothing          b.1=H            no, the pointer should be on line 03
01  symbol par=b1           nothing          b.0=H            no, the pointer should be on line 03
04  goto main               branch to 03     branch to 03     yes.
~~repeats to top
 

Attachments

Last edited:

tiscando

Senior Member
Hi again,

The problem I have just stated in post #28 just got solved, as now I know I had too many gosub commands, with the unforseen ones inside the on...gosub... command. :eek: I have just changes the gosubs into the glcd command subs area into gotos, and replaced the on...gosub into a bank of if...gotos.
After this, the program works fine now. (notwithstanding the fact that 'too many gosubs' weren't reported in PE initially)

Thanks. T
 
Last edited:

Technical

Technical Support
Staff member
Toby - have you downloaded the real 1.0.4 release as opposed the early beta release you had, that should fix the high/low/toggle issue...
 

tiscando

Senior Member
Well, here we go again: a different fault this time.

I still have the jumpy simulation problem until when I uninstalled and reinstalled PICAXE VSM 1.0.4. Finally, there's no off-target program flow with the high/low/toggle commands.

However, it didn't solve yet another fault in the same 'graphic lcd for atahdd' described in post #28, after I've modified it further after post #32, when I realized the on...gosub is making the gosub count above 256.

This time, it's not to do with having too many gosubs, as the number of 'gosub' commands in the latest version I'm talking about is about 252.
It is another program flow fault where there is access violation in axevsm1.dll [Edit: due to the underlying problem summarised in the last post]

See the attachments: first is the debug design with the glcd connected to a 40x1 with the 'graphical lcd for atahdd' program with the error, and the bottom one is the program with the fault in it (U1), the code at the bottom is for the tester 28x1 (U2).
The tester picaxe sends (9) at n9600 to U1's in0, and after U1 has completed the first duties in the 'ghex' route, and when it's program pointer reaches the 'gosub audatab0' in the 'update' sub/uchs, which is emphasized like this:
'##########*****FAULT*****##########',
the program immediately terminates with the red error of death: 'access violation in module 'axevsm1.dll'', the error I so often meet in picaxe vsm, and the error that doesn't give me any clue about the solution. :mad:
And the fault really shouldn't be there because the same program route explained above works perfectly well in PE's simulator.

Part of code where the fault is (the gray line numbers may slightly vary):
Code:
...
[COLOR="Gray"]787[/COLOR] for b4=0 to 20
[COLOR="Gray"]788[/COLOR] b0=32
[COLOR="Gray"]789[/COLOR] lookup b4,("Cylinder:"),b0
[COLOR="Gray"]790[/COLOR] b0=b0-32
[COLOR="Gray"]791[/COLOR] gosub audatab0[COLOR="Green"]'##########*****FAULT*****##########'[/COLOR]
[COLOR="Gray"]792[/COLOR] next b4
[COLOR="Gray"]793[/COLOR] b1=autoreset
...
(U2) test1.bas:
Code:
setfreq m8
pause 1000
serout 0,n4800,(%00001001)
end
Thanks.
 

Attachments

Last edited:

tiscando

Senior Member
The uncertainity is still not sorted out however...

Summary:
!. Nap command uncertainity fault (#1, #3 and #4) solved. :)

". pause skip fault (#5) is probably not really there.

£. -The general program flow/space uncertainity fault is still not fixed, as I looked at the "keypad master"@"keypad - graphic lcd" design again (which is talked about on posts #10 and #11), and I found out that the program still does not go all the way through without completely-unexpectedly stopping at one random line with one random effect (random only as in every time I change the program, not every time I run the isis simulation) e.g. just stop as if it is at an 'end' command, or terminate the simulation with violation in axevsm1.dll etc, sometimes with a random array of made-up commands:confused: that are not in the actual program before (e.g. a made-up return command) or one of the stops above. Notify me if you want me to post the full updated 'keypad master 15x7 caps graphic.bas' and other programs, the updated schematic, and to notify where and how the problem creeps around in this program.

Then I found the faults explained in the above post #34 behave just like the general uncertainity problem explained above. I'll explain exactly how it goes here:
(A change in the circuit diagram: U1's out0 is connected to U2's in0, and here's the updated 'test1.bas':
Code:
setfreq m8
do
loop until pin0=1
serout 0,n4800,(%00001001)
end
)
1. If I put a 'pause 300' (infact anything above about 300, not below 250) command after the setfreq m8 after the long symbol array, the same violation...axevsm1.dll appears on the line above "gosub audatab0'##########*****FAULT*****##########'", which is "b0=b0-32", instead.

Well, I think this problem might be thinned, but not completely solved yet, so keep the debugging up...


$. The memory usage calculation fault (#13) is definitely fixed.

%. The confusion with BLDCMotor (#15) is still not sorted out yet.

^. New problem: no .MDFs for the BLDC_Star and the BLDC_Triangle yet.
 
Last edited:

Technical

Technical Support
Staff member
We are unable to help you with this information - it is far too confused and we cannot decipher what you mean.

If you think you have an issue please provide a clear consise explanation with a 3 or 4 line program that specifically highlights the issue. We can't help if those 3 or 4 lines are buried within a huge program and complicated circuit that we just can't understand or even get to simulate, e.g your keypad programs/circuits!
 

tiscando

Senior Member
it is far too confused and we cannot decipher what you mean.
The thing is, it is not a fault of a command, it is a fault with the program flow interpreter or whatever it's called in 'axevsm1.dll', where at one line in a whole program, it seems to just rudely unexpectedly terminate the whole simulation with that error of death: internal access violation in axevsm1.dll. Where this rude termination occurs goes to a different place in the program, or disappear (or appear again) every time I make changes to the program.

This means I had to provide you the whole program, in a simpler circuit diagram than it's original in this case.
I was possibly wittering on about just one particular thing in the above posts, but I am going to really try to clarify this one fault here:

1. Download "graphical lcd debug 128x64.DSN" on post #34. Download the program to be looked at: "Graphic lcd for atahdd.BAS" also on post #34.

2. Open up programming editor (or whatever you use), and copy and paste this code:
Code:
setfreq m8
do
loop until pin0=1
serout 0,n4800,(%00001001)
end
into the untitled code window, and save this code as "test1.bas".

3. open 'graphical lcd debug...' in ISIS, and in the options of U1 (picaxe-40x1), navigate to and select the program "Graphic lcd for atahdd.BAS" as the source file. In the options of U2 (picaxe-28x1), select the program "test1.bas" as the source file.

4. Press the pause button, and in U1's code window, place a breakpoint at line 788 (address 3FB1): b0=32 (in the part of code shown below), and press run. The code window should pop up once again, with the pointer at the breakpoint. Now press the 'step down' button to step the pointer through this part of the program, and on the press of the 'step down' button with the pointer on:
791 4010 gosub audatab0'##########*****FAULT*****##########' (The address for this line is $4010)
you should suddenly see the simulation rudely terminate with the error log saying "...access violation in module AXEVSM1.dll". The next step is to find out why it is doing that.

I tested it again today, with the breakpoint on 'b0=32', and with the same rude termination at the gosub.
Part of the code with the line where the simulation terminates.
Code:
...
[COLOR="dimgray"]787[/COLOR] for b4=0 to 20
[COLOR="dimgray"]788[/COLOR] b0=32                                    <place breakpoint here.
[COLOR="dimgray"]789[/COLOR] lookup b4,("Cylinder:"),b0
[COLOR="dimgray"]790[/COLOR] b0=b0-32
[COLOR="dimgray"]791[/COLOR] gosub audatab0'##########*****FAULT*****##########'
[COLOR="dimgray"]792[/COLOR] next b4
[COLOR="dimgray"]793[/COLOR] b1=autoreset
...
I also tested it again in Programming Editor's simulator, typing 9 into the serin data popup, and of course the program did not stop at line 791 "gosub audatab0 '...", like it does in ISIS, but just carried on like properly normal and how it's supposed to, eventually back up to the serin command.
 
Last edited:

tiscando

Senior Member
The above problem is a chasing problem

I tried changing the code around, e.g. change each:
Code:
comb1m4:
low rd,ce
if portc pin0=0 or pin1=0 then comb1m4
high rd
dirsc=%11111111
pinsc=autoreset
pulsout wr,5
pauseus 2
dirsc=0
high ce
into:
b1=autoreset
gosub comb1

- until I reach the gosub limit.

But the program just keeps stopping at one command (A program flow command e.g. gosub and if.) Every time I do the above on one section, the program unexpectedly stops at a different command :( (mainly inside the 'update' sub inclusive), rather than not unexpectedly stop at any place at all, and yet I'm still under the gosub limit, until the complier says "too many gosub commands".

It is annoying that I sometimes have to fiddle with my programs - Only just to get it to simulate properly in picaxe VSM!

Could anyone do what I've stated in the above post #37 please? (unless you already did it, when you should notify me.)
 
Last edited:

Technical

Technical Support
Staff member
As already stated, we will not do any more testing with your files. We are sure you understand them, but we do not, and it is simply impossible to work with what you have provided.

For instance, the instructions given in post #37 do not work - the 28x1 program you suggest needs a switch on input 0 but in the .dsn file from post #34 there is nothing even connected to input0 and so the simulation cannot possibly work.

We are sorry if you get an error, but to find it we need to be able to trace it, which is not possible with your files. If you think you have a bug please send us a new, simple dsn, e.g. a single chip flashing an LED, with a clear basic program showing the issue.

We will not do any more testing with your graphical LCD files with complicated programs that are over 1000 lines long!
 

tiscando

Senior Member
For instance, the instructions given in post #37 do not work - the 28x1 program you suggest needs a switch on input 0 but in the .dsn file from post #34 there is nothing even connected to input0 and so the simulation cannot possibly work.
Sorry about that, the answer to all of this is that I forgot to update the .dsn file in post #34. I will update it now.

We are sorry if you get an error, but to find it we need to be able to trace it, which is not possible with your files. If you think you have a bug please send us a new, simple dsn, e.g. a single chip flashing an LED, with a clear basic program showing the issue.

We will not do any more testing with your graphical LCD files with complicated programs that are over 1000 lines long!
I said many times that this problem is to do with program length and program flow, not just one command. For example, if I shorten the program to this:
Code:
main:
b0="A"-32
gosub audatab0 [COLOR="Green"]'##########*****FAULT*****##########' (copied out of main program)[/COLOR]
end

audatab0:
low ce
for b13=0 to 255
low rd
if portc pin3=1 then dskip0
next b13
rautowrite0:
low rd
if portc pin0=0 or pin1=0 then rautowrite0
high rd
dirsc=%11111111
pinsc=autowrite
pulsout wr,5
pauseus 2
dirsc=0
goto audatab0

datab0:
low rd,ce
if portc pin0=0 or pin1=0 then datab0
high rd
dskip0:
high rd
low cd
dirsc=%11111111
pinsc=b0
pulsout wr,5
pauseus 2
high cd
dirsc=0
high ce
return
It doesn't really stop at the gosub audatab0. It only stops at the gosub audatab0'##... if it is in the main program, so that is why I have to provide you the full program (although a simplified .DSN) for this ongoing fault.

Good luck when trying the post #37 procedure again.

EDIT: I have thoroughly tested the instructions at post #37 (including downloading my involved attachments off the forum and use them in the test), and they really should be ok now. Could anyone try the post #37 procedure again please? (If you already did it, then please notify me in this thread.)
 
Last edited:
Top