No Address assigned to Variables, and Add Item (By Name) disabled in the Watch Window

codeOwl

New Member
Hi there,
I have taken an interest in electronics, and decided to learn how to program PICAXE chips. I have no prior electronics knowledge, but have 10 years as computer programmer, mainly in C#. I saw PICAXE VSM and like the concept of being able to and workout your circuit in a virtual environment, where you are not going to blow up chips, as well as you can set breakpoints in the code and step through it etc... I have purchased PICAXE VSM, and soon found, to my great disappointment, that it does not support the M2 chips, and the saga of when it will has been going on for years. But I figure oh well, I will press on as there is much I can learn on the older chips first.

I have set up the following simple circuit, where a linear potentiometer‎, is wired up to the PICAXE 08M. I can set a break point and inspect the value of b0 that I am reading the pot value into, and then change the value on the pot, step over the code, and see it has changed.
I then wanted to add b0 to the Watch Window in VSM so I can move the pot and see it change in real time.

I see there are two options to add an item to the Watch Window.
Add Items (By Name)
Add Items (By Address)

The issue I have is that the (By Name) option is greyed out, and there is no Address assigned to any of the variables in the Variable Window. There seems to be addresses assigned to the lines of code in the Program Window, however these don't help me much, as I want the Address of the b0 variable.

What am I doing wrong here?

I have attached the project here in case someone wants to try and replicate the issue:
View attachment Linear Potentiometer Test.zip

See the following pic for details of my test circuit.
http://www.spearheaditsolutions.com.au/details.png


Your help is much appreciated,

codeOwl
 

Technical

Technical Support
Staff member
Not many people use this feature in PICAXE VSM (remember VSM is a 'cut down' version of Proteus and so has some more advanced features not often used by PICAXE users).
On the older 08M b0 is byte 0x32 of the SFR RAM (on more modern parts such as M2 / X2 parts it will be a simpler arrangement, 0x00 = b0, 0X01 = b1 etc.).

So if you 'Add items by address' select the SFR RAM, type in a name (such as 'b0') and then the matching address 0x32 you should get a watch screen working as you want.
 

codeOwl

New Member
Technical,
Thanks for the response. I did a test using 0x32 for the address, as per your suggestion, but did not get the expected result. Please see the picture below:
The actual value of b0 is 179, but the watch with the address of 0x32 shows -77 as the value.


You can use the example project I attached to my first post in this thread to test the proposed solution before posting back, as this will save some time :)

Is there a look-up table some where (eg; in the PICAXE VSM documentation), where I can find all the address for the variables etc...

Regards,

codeOwl
 

Technical

Technical Support
Staff member
Your screenshot does show a value of '+179' for 0x32 in the SFR RAM window.

So you probably just have the display type within the watch window wrong - right click over it and make sure it not the wrong 'display format' - it looks to us like you are using a signed integer at present (use hex or unsigned instead).

On different chips the quickest 'cheat' way to find the variable positions is just to do something like

b0 = 0
b1 = 1
b2 = 2
b3 = 3

and then look for the pattern within the SFR RAM window. That will show you the variable positions instantly (they are sequential).
 

lbenson

Senior Member
The first clue is that -77 is a negative number, and picaxe doesn't do negatives. Less obvious: 179+77 = 256 -- 2 to the 8th -- an indication of some "wraparound" or negative/positive issue.
 

codeOwl

New Member
Your screenshot does show a value of '+179' for 0x32 in the SFR RAM window.

So you probably just have the display type within the watch window wrong - right click over it and make sure it not the wrong 'display format' - it looks to us like you are using a signed integer at present (use hex or unsigned instead).

On different chips the quickest 'cheat' way to find the variable positions is just to do something like

b0 = 0
b1 = 1
b2 = 2
b3 = 3

and then look for the pattern within the SFR RAM window. That will show you the variable positions instantly (they are sequential).
PICAXE Technical Support,
The display format I have in the Watch Window is a signed integer. This matches the display format I have in the RAM Window. I tried all the other formats, and none of the work, as the value I want to see is an integer, I see no reason why an integer format would be the problem.




Also you can see the location is at 32:


So the address is correct, but the value in the watch window is wrong.

Please don't take this the wrong way, I appreciate you taking the time to answer the posts of a paying customer. However, the process we are going through now, where you through me a suggestion without actually testing to see if it is going to work, could go on for weeks. I build software for a living. When a client contacts us with an issue, we gather the details to replicate the issue, then we attempt to replicate the issue, work out the cause, come up with a solution/work-around, test the solution/work-around, and then contact the client and assist them in applying the solution/work-around.
I have provided you with all the details, and even a test project that you can use to replicate the issue.
Please replicate the issue, work out what the problem is and test the solution, before you tell me to try something else.

Thanks again for your assistance, I do appreciate it.

Regards,

codeOwl
 

codeOwl

New Member
The first clue is that -77 is a negative number, and picaxe doesn't do negatives. Less obvious: 179+77 = 256 -- 2 to the 8th -- an indication of some "wraparound" or negative/positive issue.
lbenson,
Thanks for the clue mate. Hopfully this will assist support in tracking down the issue.

Regards,

codeOwl
 

lbenson

Senior Member
I don't have VSM, so can't test it. Your screen shot shows that the "display format" is "signed integer", so you would expect that a byte value with the high bit on (>127) would show up as a negative number because of sign extension. Does it not display correctly if you check "unsigned integer"?
 

Technical

Technical Support
Staff member
I build software for a living. When a client contacts us with an issue, we gather the details to replicate the issue, then we attempt to replicate the issue, work out the cause, come up with a solution/work-around, test the solution/work-around, and then contact the client and assist them in applying the solution/work-around.
Us too. We did test on your file, however as you did not include the required .bas file we had to write a simple equivalent from scratch - you can see it in the attached screenshot.
As correctly explained before you simply have the display type wrong in your watch window - variable 'b0' is a data type 'byte' and should be of display format 'unsigned integer' (or 'hex' if you prefer). Do that and the display will be correct. See attached screenshot from your project file - watch, variables and SFR RAM window all completely match displaying the same value (0xB3, 179).

Also signed/unsigned integers *are* completely different in all programming languages, if you have a byte length 'signed integer' your total available range is -127 to +127, not 0 to 255.
We are not sure why the SFR RAM window displays like it does on signed (we always use hex!), that looks like a bug for Labcenter to look at. However you shouldn't ever be using signed at any point anyway with PICAXE.
 

Attachments

Last edited:

codeOwl

New Member
Us too. We did test on your file, however as you did not include the required .bas file we had to write a simple equivalent from scratch - you can see it in the attached screenshot.
As correctly explained before you simply have the display type wrong in your watch window - variable 'b0' is a data type 'byte' and should be of display format 'unsigned integer' (or 'hex' if you prefer). Do that and the display will be correct. See attached screenshot from your project file - watch, variables and SFR RAM window all completely match displaying the same value (0xB3, 179).

Also signed/unsigned integers *are* completely different in all programming languages, if you have a byte length 'signed integer' your total available range is -127 to +127, not 0 to 255.
We are not sure why the SFR RAM window displays like it does on signed (we always use hex!), that looks like a bug for Labcenter to look at. However you shouldn't ever be using signed at any point anyway, so perhaps they are 'overriding' that in that window. We'll ask.
Well... I stand corrected!! An unsigned integer does show the correct value. My apologies for being a bit short in my last post, it felt like we were going round in circles, but apparently it was just me going round in circles.
Also thanks for the tip on signed/unsigned integers. I have really only had to deal with the int and long types in programming till now. I will make a note of that one ;-)

Thanks again for your time, I do appreciate it.

Regards,

codeOwl
 
Top