How To Make Picaxe Better

CDRIVE

Senior Member
Picaxe Programing Editor:

When I downloaded my new Picaxe editor for the M2 parts. I was so hoping that this version would include 'block commenting' like Visual Basic uses. Unfortunately, it doesn't. In VB, the programmer can highlight entire blocks of code and select 'Comment' on the tool bar. This action will place an apostrophe as the first character on each line. Likewise, an entire block of code can also be un-commented. Block commenting and un-commenting beats the heck out of having to do this manually on every line the programmer wants to comment. After all, commenting is used for debugging, as well as merely comments.

The following suggestions regards the simulator:

Most of my circuit designs are configured with Input pins being normally High, so I have to set them as such in the simulator. It would be nice to not start the simulation from the Simulate option in the editor, but instead have it open the simulator, let me set the Input states on the virtual buttons and then hit Run.

While we're talking about Virtual Buttons, a feature to convert them to momentary push buttons (NC-ON or NC-OFF) would be advantageous. Press key or mouse = activate, Release = deactivate.

My last suggestion of my wish list has nothing to do with the Picaxe editor or simulator. It has to do with Spicing Picaxe. I have a copy of Picaxe_VSM (Proteus) but it's not my preferred spice software. I use 'Tina' primarily but they currently don't support Picaxe. It's been over a year since I asked them to do so. Perhaps Picaxe can convince them otherwise? ;)

Thank you,
Chris
 

nick12ab

Senior Member
When I downloaded my new Picaxe editor for the M2 parts. I was so hoping that this version would include 'block commenting' like Visual Basic uses. Unfortunately, it doesn't. In VB, the programmer can highlight entire blocks of code and select 'Comment' on the tool bar. This action will place an apostrophe as the first character on each line. Likewise, an entire block of code can also be un-commented. Block commenting and un-commenting beats the heck out of having to do this manually on every line the programmer wants to comment. After all, commenting is used for debugging, as well as merely comments.
You can use #rem and #endrem directives to comment out multiple lines of code, however I do agree that a toolbar button to do it would be helpful. I do find myself having to do it in Visual Basic a lot more often though and I haven't noticed the toolbar button in there and I've always had to manually comment out each line so is this VB6 only?
 

Technical

Technical Support
Staff member
My last suggestion of my wish list has nothing to do with the Picaxe editor or simulator. It has to do with Spicing Picaxe. I have a copy of Picaxe_VSM (Proteus) but it's not my preferred spice software. I use 'Tina' primarily but they currently don't support Picaxe. It's been over a year since I asked them to do so. Perhaps Picaxe can convince them otherwise? ;)
You cannot 'spice' a PICAXE, as it in not an analogue component. You therefore need a co-simulation product (spice and digital simulation overlaid) such as PICAXE VSM. This is extremely complex to develop and each MCU needs developing separately.

The other requests are already on our wishlist.
 

nick12ab

Senior Member
You cannot 'spice' a PICAXE, as it in not an analogue component. You therefore need a co-simulation product (spice and digital simulation overlaid) such as PICAXE VSM. This is extremely complex to develop and each MCU needs developing separately.
MCUs are made of transistors and they're analogue components so isn't it possible to just reconstruct a PIC microcontroller out of individual MOSFETs? (construct a hard-wired ROM for the program memory occupied by the interpreter)

Or is that just a stupid suggestion that would take an unrealistically large amount of time?
 

mrburnette

Senior Member
As nick12ab says, #rem and #endrem are useful.
You may also investigate the PE 'block' commands to collapse large sections of code into modules. That may help.

- Ray

PICAXE block code example.JPG
 

CDRIVE

Senior Member
You cannot 'spice' a PICAXE, as it in not an analogue component. You therefore need a co-simulation product (spice and digital simulation overlaid) such as PICAXE VSM. This is extremely complex to develop and each MCU needs developing separately.

The other requests are already on our wishlist.
Tina already has most of the PIC/Microchip spice models in their library. PICs and other microcontrollers are handled under their MCU tab which allows for code editing & linking just like ISIS/Proteus (Picaxe_VSM). Unfortunately Picaxe is not one of them. Tina doesn't have to supply a code editor for Picaxe though. They can use the same file linking system that ISIS/Proteus uses to link Picaxe *.bas files to the current Picaxe VSM schematic/spice simulation.

As I said earlier, I have Picaxe VSM but I prefer Tina for too many reasons to state here. I really dislike the large clunky models that Picaxe VSM uses. They take up an awful lot of real estate and it's no where near as fast and easy to use as Tina. I can draw and simulate just about any circuit in Tina in about 1/10th the time it takes me to do it in Picaxe VSM.

Chris
 

CDRIVE

Senior Member
You can use #rem and #endrem directives to comment out multiple lines of code, however I do agree that a toolbar button to do it would be helpful. I do find myself having to do it in Visual Basic a lot more often though and I haven't noticed the toolbar button in there and I've always had to manually comment out each line so is this VB6 only?
Thank you for the tip. I was unaware of those directives. Not as handy as VB's system but a heck of a lot better than remming line by line. What version of VB are you using. I use VB6 but I'm sure NET has the same remming conventions.

Chris
 

CDRIVE

Senior Member
As nick12ab says, #rem and #endrem are useful.
You may also investigate the PE 'block' commands to collapse large sections of code into modules. That may help.

- Ray

View attachment 11346
Thanks Ray. This is another useful tip. I've been using Picaxe for quite a few years now. I'm amazed that I missed these directives all these years. Heck, it's right at the beginning of the Basic Commands pdf! Duh!!

Chris
 

CDRIVE

Senior Member
Visual Basic 2008 Express Edition (which is .NET).
So, have you found it yet? I don't use NET but I'm sure it's there. It should be on one of your tool bars. Hover your mouse over the icons until the tool tips are visible.

Chris
 

nick12ab

Senior Member
So, have you found it yet? I don't use NET but I'm sure it's there. It should be on one of your tool bars. Hover your mouse over the icons until the tool tips are visible.

Chris
I could not find it. According to this,
In VB, the apostrophe is the only comment marker, so it has to go on each line. HOWEVER: if you are using VS.NET, you can highlight a block of code and then use Edit | Advanced | comment selection / Uncomment Selection to add or remove comment marks on the highlighted lines.
So it is only in Visual Studio and not in the 'poorman's' Express edition.
 

CDRIVE

Senior Member
There was something that I missed on the Picaxe wish list. That would be Capitalization on Keywords like VB uses. When I write code in Picaxe I do it manually because it looks better and is easier to read. Like this..

Main:
If B0 = 3 Then
High 3
ElseIf
B0 > 3 Then
High 2
Else
Low 3
EndIF


Edit: I included indentation , which is ignored too often by some coders, but is important in readability of code. This editor removed my formatting??
 

CDRIVE

Senior Member
Yes; you need to wrap it in [code]...[/code] tags to retain indentation.
Ah, I've been posting in the 'Quick Reply' window. I now see that I have to select the 'Advanced' button to bring up the full reply window that includes the toolbar with code tags selection. Dunka! ;)

Code:
Main:

   If B0 = 3 Then
       High 1
   ElseIf B0 > 3 Then
       High 2
   Else
       Low 1
   EndIF

GoTo Main
 

oracacle

Senior Member
this may be long shot but how about being able to run multiple instances of the editor with the abilty to each use differnt com ports and programme different picaxes, so the a slave programme on a 20x2 cna be modifed along with say a master 40x2 programmed with only having to switch windows instead going though the option every time
 

nick12ab

Senior Member
this may be long shot but how about being able to run multiple instances of the editor with the abilty to each use differnt com ports and programme different picaxes, so the a slave programme on a 20x2 cna be modifed along with say a master 40x2 programmed with only having to switch windows instead going though the option every time
Use the #com directive in your programs to automatically select the correct port. However I think in the latest version of Programming Editor you are allowed multiple instances anyway.
 

westaust55

Moderator
However I think in the latest version of Programming Editor you are allowed multiple instances anyway.
My observation is that the latest version will allow you to open a new instance (either directly or by clicking on an exisitng .bas file) but that the previous instance is shut down.
You are given the option to save changes to any open program code in the previous instance if it has not been saved since last changed.
 

nick12ab

Senior Member
My observation is that the latest version will allow you to open a new instance (either directly or by clicking on an exisitng .bas file) but that the previous instance is shut down.
You are given the option to save changes to any open program code in the previous instance if it has not been saved since last changed.
If you press 'Cancel' when the option to save changes appears, both instances stay open.
 

CDRIVE

Senior Member
While we're talking about editor and simulator improvements the DAC output could use some new clothes. How about an actual (computed) voltage reading?
 

pleiser

Senior Member
Picaxe Programing Editor:

...
While we're talking about Virtual Buttons, a feature to convert them to momentary push buttons (NC-ON or NC-OFF) would be advantageous. Press key or mouse = activate, Release = deactivate.
...

Thank you,
Chris
I agree this would be helpful, but please don't remove current functionality (click to toggle) but instead make both avalible (maybe 2 buttons one for each function)
 

nick12ab

Senior Member
I agree this would be helpful, but please don't remove current functionality (click to toggle) but instead make both avalible (maybe 2 buttons one for each function)
Or use the Shift key to hold the state like a certain competitor.
 

CDRIVE

Senior Member
I think the best system would be 'hover over the pin, mouse right click menu, select momentary (NO), Momentary (NC), etc but let's not forget a voltage display for the DAC.
 

nick12ab

Senior Member
MCUs are made of transistors and they're analogue components so isn't it possible to just reconstruct a PIC microcontroller out of individual MOSFETs? (construct a hard-wired ROM for the program memory occupied by the interpreter)
Was this a stupid suggestion?
 

Buzby

Senior Member
... Was this a stupid suggestion ? ...
I don't think any question should be called 'stupid', it all depends on the context, and the naivety of the questioner.

An MCU is indeed made of transistors, but they're not normal transistors like our three-legged friends.
The world inside an IC is if full of strange animals, like six-legged transistors, and three-legged diodes, and other creatures so weird they don't have any relations in the outside world. So simulation at the analogue level is impractical.

However, any MCU is just a bunch of gates, registers and counters all joined with wires.

It is much easier to replicate these with a digital logic simulator, and I've no doubt that it could be done, but there is a still easier method.

An MCU changes the values of registers etc. in response to the opcodes executed.

The way the MCU does this is by decoding, in hardware, the bit pattern of the opcode, which then results in more hardware being used to perform whatever function is needed.

A simulation which replicates the logical function of the opcode, but not the hardware, is much easier to write.

Once you've got software to replicate all the opcode functions you have got most of the CPU part of the MCU emulated, and it will be able to 'run' sequences of opcodes just the same as a real CPU. Some more work to add timers and I/O and your virtual MCU is complete.

Something like a PIC or AR*****O would be a major task to undertake, but an 'old' MCU like the SC/MP 8060 is a lot simpler, and it is reasonable easy to follow how it works.

( See http://www.robsons.org.uk/archive/members.aol.com/mk14emu/a86src.htm
Download the 'assembler source' zip file, then look at the file called cpu.c )

After you have your virtual MCU, say a 6502, you can write code around it to simulate a specific computer, such as an Apple or a BBC.

Moving up a step you could virtualise a modern CPU, and make a virtual PC.
This is exactly what a Virtual Machine (VM) is.

I don't know how the simulator in PE works.

It may have a virtual PIC, which is running virtual firmware, and so behaves as a PICAXE.
This virtual PICAXE would then run the tokenised BASIC that the PE compiler generates.

Or the PE may take a totally different approach, and have just an interpreter for the BASIC at one level and emulate the hardware at another, without the virtual 'firmware running on a PIC'.

Only Rev-Ed know how it's done, but I don't think they'll tell us !.

Cheers,

Buzby
 

nick12ab

Senior Member
An MCU is indeed made of transistors, but they're not normal transistors like our three-legged friends.
The world inside an IC is if full of strange animals, like six-legged transistors, and three-legged diodes, and other creatures so weird they don't have any relations in the outside world. So simulation at the analogue level is impractical.

However, any MCU is just a bunch of gates, registers and counters all joined with wires.
I've seen transistors with multiple collectors or emitters in datasheets - but only for bipolar logic devices - CMOS devices just used normal three-legged MOSFETs. So do these six-legged transistors still apply to PIC microcontrollers (which are CMOS, aren't they)?
 

hippy

Technical Support
Staff member
A simulation which replicates the logical function of the opcode, but not the hardware, is much easier to write.
And importantly simulation executes much quicker than emulating a device at gate level.

It can be done either way and each has their pro's and con's. Writing a simulator is often easier than writing an emulator and usually has no greater risk of being an incorrect simulation than an emulator has of being an incorrect emulation. As simulation usually runs more quickly that's often the best choice to make, which is how it's done with PICAXE VSM models and Simulation under Programming Editor.
 
Top