Programming Editor Wishlist

nick12ab

Senior Member
In a project I need to stop a pump when a fixed number of pulses from a flow sensor has been reached.
So I count the pulses in a subroutine during 1 second until NumberOfPulses > Value.

Code:
CountPulses:
    count FlowSensor,100,NumberOfPulses
    PulseCounter = PulseCounter + NumberOfPulses
return
Problem is that during the rest of the program pulses are being lost.

It would be great if the COUNT command had an parameter that makes the command count until that number of pulses has been reached.
If you use a 28X1, 40X1, 28X2 or 40X2 then you can use the external timer which runs in the background. If not, then you can manually implement counting.

Code section for manual counting extracted from previous project:
Code:
check:if reed = 1 then
        if reedstatus = 0 then
            inc loopcounter
            reedstatus = 1
        end if
    else
        reedstatus = 0
    end if
'put whatever code you want here
    goto check
Make 'reed' the input you're counting (originally a reed switch), reedstatus a bit variable and loopcounter a word or byte variable.

ADDED: If this is a follow-up to a previous thread say so so that members like me who may have not been following your work don't repeat suggestions that you decided was inappropriate.

EDIT: I've looked at your past posts and this does not appear to be a continuation but rather a Programming Editor suggestion. I'd think that not being able to terminate 'count' is a limitation of the PICAXE itself and not Programming Editor. I'd suggest using one of the two methods above.
 
Last edited:

papaof2

Senior Member
That sounds as though the count of pulses might be better handled by an interrupt.

Code:
'Air code - untested

setint #00000001, 000001  'pin 1

main:

'your other code

B7 = 1  'set a flag when pulses should be counted

'other code

B7 = 0  'reset flag when pulses should be ignored

goto main

interrupt:
  if B7 = 0 then 
    setint #00000001, 000001  'activate interrupts
  return  'exit function if not countig pulses

  'do pulse counting stuff here

setint #00000001, 000001  'activate interrupts

return
 
Last edited by a moderator:

inglewoodpete

Senior Member
I have to agree. Counting pulses to a maximum with overriding time supervision can be done relatively simply in code, particularly on the X2 models.

I used this technique in the Background Infrared Receiver. Note that the IR receiver code is much more sophisticated in that it measures and records the width of each pulse cycle. However, the principles are the same: use of hardware and timer interrupts concurrently.

I don't want to sound too much like a wet blanket on the idea of a time-limited, count-limited function that was proposed. But the concept is not something that can be just added to the programming editor (which this thread is about). Such a command could be developed in the firmware of a PICAXE but it would be quite sophisticated and may be limited to a very small market.

I'm sure that Rev-Ed are not sitting on their hands. The resources available to Rev-Ed are limited, like any small business. Development of PICAXE appears to alternate between surges in the chips' capability and development of the programming editor. In recent times we have seen fantastic changes in the PICAXE range with the introduction of the -M2 series and the redevelopment of the -X2s. To be honest, the PE is a little clunky for 2012 and I look forward to a new version. And I remember the times when we didn't have the colour editor, If-Then-Else and Select-Case structures or Do-Loops.
 

inglewoodpete

Senior Member
Another idea: bit addressing

I recently had a need for setting and clearing bits in a byte (could easily have been a word) and found that it is not the simplest thing to do.

Eg
Code:
(Let) Bit  b10, (b6) = pinB.1    'Where b6 contains a value 0-7
(Let) Bit  w10, (b6) = pinB.1    'Where b6 contains a value 0-15
It's true that we have the ClearBit and SetBit commands but these have to be placed in an If-Then-Else structure, testing the state of the input pin. Alternately, we can use a mask to And / Or the state of the bit in question but that also requires the maintenace of a byte or word mask in a variable.

Is this something that can magically be provided in the programming editor or would it require changes to the firmware?

Alternatively, is there a clever manipulation of commands that can already do what I want? - hippy always seems to surprise us in this area!
 
Last edited:

hippy

Ex-Staff (retired)
Is this something that can magically be provided in the programming editor or would it require changes to the firmware?
For maximum execution speed and smallest code size a command usually has to be supported in firmware but it can alternatively be done using a sequence of existing commands which is hidden from the user.

The problem with firmware additions is limited space available and the knock-on consequences and for 'hidden expansion' people may not appreciate why a seemingly innocuous command may require more code and run slower than they expected.

In both cases it's additional work in design and testing, and in catering for special cases such as use of special variables (s_w0) which may need to be handled differently and so on. The bottom line on any additions therefore is a technical and business decision; is it possible, does it have validity, is it beneficial to have, does it return more than it takes to deliver, and is there something else better to allocate resources to. One factor always will be; is there some existing way for what's wanted to be done already?

I can't off-hand think of any clever trick to do what you want other than by use of an IF and a mask variable or BITSET / BITCLEAR commands.
 

Jeff Bobbo

New Member
I'm not sure if it's been suggested yet already. But a better Find/Find & Replace would be awesome. Extra options for in selection, wrapping and direction (for find & replace) would be really awesome.

Being able to see bytes and words at the same time while running a simulation would be good, as well as seeing words in binary (Yes, I'm crazy.)

And finally, allowing us to scroll through our code while the debug window is up... So annoying when you're stuck looking at one screens worth.
 

hippy

Ex-Staff (retired)
The areas of SFR which can be used as 'general purpose RAM' can be displayed but there's no support for peripheral controlling SFR; that would require a complete PICmicro simulation which is beyond the scope of PICAXE simulation.
 

lbenson

Senior Member
I don't know whether this has been mentioned before, but "servo" takes a "variable/constant" for pin, but "servopos" takes only a constant. It would be helpful if servopos also allowed a variable.
 

BillyGreen1973

Senior Member
I may be reading this wrong, but SERVOPOS does take a variable.

from the Basic Commands pdf...

SERVOPOS pin,pulse
SERVOPOS pin,OFF
Pin - is a constant which specifies the i/o pin to use.
Pulse - is variable/constant (75-225) which specifies the servo position
 

Technical

Technical Support
Staff member
'servopos' on many of the parts is not actually a real command, but parses as a 'pokesfr' on an appropriate register. The compiler can only do this if it knows which pin to use at compile time, which is not possible with a pin variable. On X2 parts this system was already changed, so X2's do allow a pin variable.

On other parts a possible workaround is

Code:
select case b1
    case 0
        servopos 0,b2
    case 1
        servopos 1,b2
etc.
end select
 

photomankc

New Member
Not sure if already mentioned but a way to edit values in scratch-pad eeprom. I'd like to simulate I2C commands to a slave but can't really because they are pulled in from the scratch-pad which I can't edit and I see no way to send any I2C data *TO* the simulator.
 

Jamster

Senior Member
Another thing: I would like to be able to simulate two programs at once and be able to "link" pins so if you set a pin high in one simulation or send a serial string from it, it will be set high or receive the string at the other simulation on the assigned pin. Would be great for debugging the many "Can I get my PICAXEs to talk" threads as well as the many other uses. :)
 

Haku

Senior Member
Full page scroll option (instead of just three lines).
Bit late I know, but PageUp & PageDown buttons on your keyboard will scroll whole page up/down as they should :)

But this brings up an addition I would like, as well as PgUp & PgDn it would be nice to be able to press Ctrl and use the scrollwheel on the mouse to move whole pages up/down, a program I use which deals with long lists has the Ctrl+Scrollwheel thing and it's extremely useful.
 

techElder

Well-known member
CTRL + SCROLLWHEEL will increase and decrease font size in a lot of programs. Perhaps a different key combination?
 

Hydroid

Senior Member
Not sure if already mentioned (list is getting Loooooong...), but:

Better 'Compile Error / Syntax Check' messages.

Example:

Code:
serin  T4800_4, ("$GPRMC,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0
when Syntax checked gives:

Code:
serin  T4800_4, ("$GPRMC,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0
                 ^

Error: Syntax error in this line!
with the carat under the first quote symbol of '$GPRMC' - makes you think that's where the problem is even though it's actually because the 'Pin# and comma' are missing after 'serin':

Code:
serin 0, T4800_4, ("$GPRMC,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0
Even worse on some longer lines of code where the error is nowhere near the indicator. If it can't point to the error location(s) for some technical reason, then not having it there would at least not point you in the wrong area.

Get mislead by that pointer way to often - but it does promote learning - and a LOT of head-scratching :)

John.
 

nick12ab

Senior Member
Better 'Compile Error / Syntax Check' messages.
I also have an example to contribute:
Code:
  lookup loopcounter,("Set thermistor ",bta5,),lcddata
                                                   ^

Error: Syntax error in this line!
The problem is the comma after bta5, but the caret points at lcddata, which is properly defined in the symbols area.
 

Haku

Senior Member
CTRL + SCROLLWHEEL will increase and decrease font size in a lot of programs. Perhaps a different key combination?
Good point, on FireFox pressing Alt + Scrollwheel makes it scroll single increments instead of 3 (or whatever you set the scrollwheel to), which leaves Shift + Scrollwheel. Possible to impliment that as a whole page up/down scrolling?
 

Haku

Senior Member
Further to the requested feature of automatically saving your program(s) you're editing evey X minutes, I've thought of a further feature I'd like:

Session Saving. With automatic saving every X minutes in case of power loss etc.

I'd like the ability to save all the programs you're currently editing (or a selected group) as one session file, enabling you to click Save Session, so you can turn off your computer and then come back to it at any time by selecting Load Session and all the programs you were previously editing load up in one go, with the window size/position just as before.

I find when I'm working on a project and testing various bits of code, copying the whole core code to a new editing window to 'sandbox' with is preferable to editing the only working code, that way if you mess it up you still have the original to fall back on. Being able to save the session (including the sandboxing code which isn't saved in a .bas anywhere) would be a great benefit.
 

Haku

Senior Member
In the middle of doing some coding and it got me thinking, when defining symbols to byte/word variables and you've got a lot of them it would be very handy to have them automatically selected for you so you don't accidentally choose a variables that clash with other variables, notably stopping you from accidentally choosing a byte variable that's part of a word variable you're using.

eg:

symbol test=BX
symbol counted=WX
symbol missed=WX
symbol percent=BX

Where putting BX or WX into the symbol directive the programming editor will automatically assign non-clashing word & byte variables to them and it doesn't matter what the programming editor selects because your code will use the name you gave them not the direct b0,w0 etc., but still have the ability to manually assign byte & word variables in the cases when you want to use bit directives on those variables etc.
 

smcmaster

New Member
These are my suggestions:
1- real functions and function calls, i.e.
b5 = my_func(b0, b1, b2)

where the function is defined some where like so,
byte my_func(byte a, byte b, byte c) begin
byte temp;
temp = (a * b * c)/3;
return temp;
end

2- The ability to split programs across multiple files, i.e. like an include const.bas file for constants or include math.bas for math functions

Just those would be a HUGE improvement in horsepower
 

mjy58

Member
Switching active window

When switching between windows with CTRL F6.

Change behaviour so the window switched to, is immediately in 'focus' (with the cursor where it was previously), rather than having to mouse click in the window to bring it into 'focus'.

This would remove an unnecessary mouse click every time a window is toggled.
 

Aresby

New Member
...Change behaviour so the window switched to, is immediately in 'focus' (with the cursor where it was previously), rather than having to mouse click in the window to bring it into 'focus'.

This would remove an unnecessary mouse click every time a window is toggled.
On that topic how about being to have both the mini-help window open as well as being able to edit (or even scroll) the main window. Applies also to serial (debug) window and several others.

Basically, allow a true multi-window interface rather than the one currently in-focus preventing switching to another.

(Apologies if this has been mentioned before; the thread is now too long to read from the beginning).
 

sid

Senior Member
Big buttons linking direct to the manuals.

From the number of questions you see on the forums, that are answered just by looking in the manuals, it may not be obvious that they are to be found under \help
How about being about to right click or highlight an "instruction" which then links to the description in the manual. a bit like highlighting a word on a kindle that then gives a dictionary description of said word, this would save opening a manual and hunting for the description manually
 

eclectic

Moderator
How about being about to right click or highlight an "instruction" which then links to the description in the manual. a bit like highlighting a word on a kindle that then gives a dictionary description of said word, this would save opening a manual and hunting for the description manually
There's the F1 option in P.E.

e
 

shoei600

New Member
This may already be covered elsewhere, or even exist, but I would like to see a 'resource monitor' that keeps track of the variables/words avaialble within the selected chip and what has been used in the code. This would be a block of buttons that show on/off rather than a list so its clear to see at a glance.

I believe this may be my first post so just while writing I'd just like to say...Picaxe, this forum, the very helpful contributions and the kindness of those that put thier code and projects up for others is simply first class and testament to those of you that play an active role. It is perhaps one of the only successful forums I have seen before that really works well and as a relative newbie still learning, I have sat on the side, used some of that code and read many posts while I get through some of the same issues others have had over the years. It is this forum, its member contributions and a great product that I'm sure has kept the interest of many that may otherwise have moved away when their projects got too difficult. Full credit to you all, well done and thank you.
 

SAborn

Senior Member
Shoei600,

In many ways it should not be needed if you lay your code out correctly and use symbols, that way you have a running list of what variables have been used at the top of your code.

It might just be a matter of you adjusting your way of constructing the code rather than PE highlighting what has been used in spagetti code.

There is the odd time that your thought could be useful, but 99% of code should not require it.
 

shoei600

New Member
Agreed, and I do always use symbols, but I often find its not so clear which bytes need to be avoided because the corresponding word is already used and is not immediately obvious.

Especially when I have used somebody else's well developed code to start with, as newbies might. This is already monitored by the software it would be nice to see it presented differently. Save me having to put them all into MS Excel each time.
 

SAborn

Senior Member
Ok point taken.

It still comes back to code structure, (yours or someone elses), and im no angel with code structure at times too, but i often start at one end with byte variables (the low end b0, b1,....) and at the high end for word variables (w13, w12,...) and work backwards with word variables, this saves having to check if variables overlap all the time, and makes selecting the next free variable much easier.
 

sid

Senior Member
There's the F1 option in P.E.

e
Well I never knew that !
That's a helpful tool, but to take it one stage further when pressing the "The detailed help and examples" button it's a shame it doesn't take you to the relevant section" in the manual rather than just taking you to the start of the manual.

Perhaps additional entry's could be made about each command detailing the common mistakes that are often made when using that particular command, or as I have only recently found out limitations of certain commands eg: timing issues when using the servo command and an input command in the same section of code. This would be of particular help to less experienced users like myself and would perhaps free up the forum from repetitive questions.
 

mjy58

Member
Code check

I realise it is not possible to reverse compile the executable code in the PICAXE back to the BASIC source code.

However, would it be possible to include a 'Check code' option. i.e. 'is the code that the compiler is going to produce from this source code the same as the code that is currently in the PICAXE' - Yes/No

This would allow one to check that the BASIC you are looking at in the editor is in fact what you have programmed into the chip.

Or more likely 'now which version of this code did I actually program into the chip?':rolleyes:
 

premelec

Senior Member
It would often be useful to know which program is loaded on a chip - perhaps an 8 byte code you could load with the program that would show up when you asked for Version - e.g. directive #progID "foo12B3a" - with the larger memory than the old 08s 8 bytes optionally loaded wouldn't be much burden on the memory... Version would then read this code to identify your program together with chip version...
 

Hendriks

Member
Another small issue, when having multiple editor windows open I would like to be able to see the name of the file in the caption of the window.
Actually it is already there but it shows the complete path which is too long to show the name also.
 
Top