Extra PICAXE Wizards

nick12ab

Senior Member
This is simply a program programmed in VB.NET that provides 'wizards' that are not (yet) in Programming Editor. It is Windows only and requires the .NET Framework and is compatible with Windows 98 onwards. It can calculate:
  • hsersetup baud value (the actual values and error % on the PICAXE from using a non-decimal number)
  • settimer preload value (the actual values and error % on the PICAXE from using a non-decimal number)
  • hintsetup wizard (added in version 1.3)
  • compsetup wizard (added in version 1.3, updated in version 1.9 to support all X2 PICAXEs)
  • tmr3setup wizard (added in version 1.4)
  • adcconfig wizard (added in version 1.5)
  • dacsetup wizard (added in version 1.6)
  • potential divider wizard (added in version 1.7, has ADC-to-Voltage multiplier calculation in version 1.8, has multiplier selection in version 1.8.3)
  • resistor colour code wizard (added in version 1.7, has label showing resistance in version 1.10.3)
  • dec/hex/bin/oct integer conversion (added in version 1.8)
  • UPDATED interactive bitmap lookup/table/eeprom command generator (added in version 1.10, has and/or/xor/not operands in version 1.10.1, updated in version 1.10.2, has import function in version 1.11, has maximize/minimize feature in 1.12.1, fixed flicker in 1.12.2, supports C-style arrays in version 1.13)
  • setint wizard (added in version 1.12)
Please click the link below to jump to the latest version.
----------> Quick link to latest version <----------

Latest screenshot:



[hr][/hr]
First version screenshots:



Choosing to disable hserin and hserout at the same time causes the wizard to produce 'hsersetup off' in the command box and hides the baud settings, actual baud rate and error since those become irrelevant.



When the external clock is selected, the interval selection is replaced with somewhere to specify how many pulses are required to increment the timer variable.

The attachment is a zip containing an exe, rather than a renamed exe. The 'PICAXE Calculator' zip file contains the program and the sourcex.y.z folders contain the VB.NET source code including form code, form designer file, icons, bitmaps, project file and solution file.

To see how each command is calculated, see the source code for the latest version.

Comments, suggestions for improvements and extra calculators, and nitpicking are all welcome.

Licensing: Free for any use, but attribution required for reuse of original code.

Latest version at the end of this thread - the version below is the first version.
 

Attachments

Last edited:

BeanieBots

Moderator
I think such wizards would be a very useful addition, though they should probably be under an "advanced" tab to not confuse the newbies.
Calculating pre-load values for obscure intervals is certainly a chore I find myself doing frequently and often get wrong. Having the ability to put in ACTUAL clock speed and calculating error from desired would be a real bonus.

This might be better off in the Editor Wishlist thread.
 

nick12ab

Senior Member
Calculating pre-load values for obscure intervals is certainly a chore I find myself doing frequently and often get wrong. Having the ability to put in ACTUAL clock speed and calculating error from desired would be a real bonus.
Is this about a desired function in P.E. or in my program? In my program you can just type any frequency to the nearest 1Hz in the clock speed control and select the 'Other' radio button to enable selection of any interval for the timer.

This might be better off in the Editor Wishlist thread.
Can you move it there please?
 

nick12ab

Senior Member
Version 1.1



Added:
  • Always on Top option for keeping the window on top of everything so that it could be kept open at the same time as Programming Editor
Changes:
  • Frequency selection NumericUpDown moved to right of tabs and label removed since unit makes it obvious what this is
  • Form made a little smaller
  • Info text now in read-only textboxes
I'm also releasing the source code.
 

Attachments

Last edited:

nick12ab

Senior Member
Version 1.2



Added:
  • Minimize to tray option (minimizes to tray when window becomes inactive (e.g. when going back to Programming Editor) and is restored by clicking the tray icon)
    • This is optional - enable it with the
      /
      checkbutton
  • Tooltips
  • New icon which is a cross between the PICAXE icon and the calculator icon
  • Window location and checkbutton options are now saved to registry
Again, comments etc. are welcome and the application and source code are attached.
 

Attachments

nick12ab

Senior Member
Version 1.3





Added:
  • Hardware interrupts wizard.
  • Comparators wizard (with interactive schematic where you can click the switches to toggle them.
Changes:
  • Tabs now only show names of commands themselves since each wizard calculates the entire command.
  • Maximum allowed baud rate for hsersetup is now halved after reading Technical's statement of a hsersetup baud_value of zero turns hsersetup off. I should have noticed before since with the PIC's clock divider taken into account, it would have been impossible to have a baud rate of one million when the UART could only toggle pin state 500,000 times a second with a 4MHz resonator.
The new version is attached. I'll attach the source code tomorrow.

If any of the wizards produce incorrect commands, please reply saying so.
 

Attachments

Last edited:

nick12ab

Senior Member
Version 1.3.1 - Minor Update



Added:
  • Red crosses appear on top of disabled comparators to make it clearer which ones have been disabled.
@IronJungle - Take a look here. Of course another reason why software isn't developed for Mac as much could be because not many people have them since the entry level Mac costs over twice as much as an entry level PC.

About half of the time, you can get Windows for free legally since Microsoft release betas and release candidates of Windows before they release them. So you could download the Windows 8 Developer Preview and install it in bootcamp or whatever.
 

Attachments

Last edited:

BillyGreen1973

Senior Member
These 'extra wizards' are a stand alone software and can run alongside PE.
These are written by a non rev-ed human ;) (forum member Nick12ab)
 

nick12ab

Senior Member
Version 1.3.2 - Minor Update



Added:
  • Little comparator flag icons (
    ) appear when 'Change sets compflag' option enabled
  • Clock frequency saved to registry on exit so that it is remembered for next time the program is run
  • Selected tab index also saved to registry so that the last used tab is the active one when the program is next started
[HR][/HR]And yes, the wizards are definately standalone and have no dependencies on Programming Editor at all, all that is required is that .NET Framework 2.0 is installed. Although it would be nice if I could program it to insert the generated code into Programming Editor.

I don't think I've mentioned yet that the source code is for Visual Basic 2008 and might not work in Visual Basic 2005 or older versions. Visual Basic 2010 (and later versions too later this year) might show a conversion wizard and following that should be fine.

Visual Basic is quite an easy language to follow so anyone's free to convert it into a programming language for a non-Windows operating system. There might even be a Visual basic compiler for Mac and Linux!
 

Attachments

nick12ab

Senior Member
Version 1.4



Only two items in total are on the lists this time but they are major.

Added:
  • tmr3setup wizard added.
Changes:
  • Copy to clipboard buttons replaced with Insert into PICAXE Editor button which is compatible with PICAXE Programming Editor, AXEPAD and my own rubbish editor. Since it just inserts text into the first window with its title containing "Programming Editor", "AXEpad" or "AXElite" (checked in that order) it might select the wrong window if there is another window open containg that title.
 

Attachments

Last edited:

nick12ab

Senior Member
Version 1.6



Added:
  • dacsetup wizard
Changes:
  • External reference pins in adcconfig wizard now renamed "Vref+" and "Vref-"
  • Frequency selector moved and resized to fit new tab
Comments etc. welcome.
 

Attachments

nick12ab

Senior Member
Version 1.6.1

This is just a minor update to fix an issue I've noticed - if the PICAXE clock speed is set above that required for a one second interval to be selectable for the timer wizard, an error will be shown on startup. The default selected timer interval is now 0.1.
 

Attachments

techElder

Well-known member
How about a wizard that does the calcs for choosing a voltage divider (available resistances) - voltage reference - ADC - to etc.? Etc. = display, bcd, binary, blah blah blah

No pressure ... ;)
 

fernando_g

Senior Member
Nick:
how come, when I click the wizard, a red dialog box appears: "Reformatting Hard Drive" ??

Just kidding :) :) :) This is a GREAT wizard! Thanks for sharing.
 

nick12ab

Senior Member
I'm doing the potential divider part but there's a problem - when the program is used, changing a value might make the program crash. This is the new code:
Code:
    Private Sub Vin_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Vin.ValueChanged
        CalculateVout()
    End Sub

    Sub CalculateVout()
        Try
            Vout.Value = R2.Value / (R1.Value + R2.Value) * Vin.Value
        Catch
        End Try
    End Sub

    Private Sub R1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles R1.ValueChanged
        CalculateVout()
    End Sub

    Private Sub Vout_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Vout.ValueChanged
        Try
            Vin.Value = ((R1.Value + R2.Value) / R2.Value) * Vout.Value
        Catch
        End Try
    End Sub

    Private Sub R2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles R2.ValueChanged
        CalculateVout()
    End Sub
R1, R2, Vout and Vin are NumericUpDown controls with decimals enabled.

I suspect the issue might be that the code gets stuck in an endless cycle of executing the CalculateVout sub since another value changes but I'd expect that just to freeze the application rather than causing a crash - "Sorry but this program has encountered a problem and has to close"
 

nick12ab

Senior Member
Version 1.7

I decided to just provide radio buttons to select what is to be calculated to eliminate the below problem:
I suspect the issue might be that the code gets stuck in an endless cycle of executing the CalculateVout sub since another value changes but I'd expect that just to freeze the application rather than causing a crash - "Sorry but this program has encountered a problem and has to close"
I am sure that this is what happened then.





Added:
  • Potential divider wizard
    • Calculates resistors, current, voltages and impedance
    • Vin, Vout and R1 can be calculated from other three from Vin, Vout, R1 and R2
    • ADC value calculator is also present for both 8-bit and 10-bit ADC readings
    • Warnings are shown at the bottom when necessary
  • Resistor colour code calculator wizard
    • Calculates colours from resistance and tolerance
    • Calculates resistance and tolerance from colours
  • Radio buttons to select between 'PICAXE-specific wizards' and 'Other electronics wizards'
Changes:
  • Form made bigger and tabcontrol moved down to fit wizard selection radio buttons
  • Clock speed selector moved in line with radio buttons rather than tabs

Please report any incorrect calculations.

How about a wizard that does the calcs for choosing a voltage divider (available resistances) - voltage reference - ADC - to etc.? Etc. = display, bcd, binary, blah blah blah

No pressure ... ;)
So that's voltage divider, ADC and voltage reference (sort of) done. BCD and binary - I'll start work on those.
 

Attachments

techElder

Well-known member
Nick, the wizard worked just great for me with some known values. Nothing locked up or reset.

The thing that I see you could add is the multiplier(s) needed to get the ADC value back into human readable form with the decimal precision wanted.

For example, we use 15Vin, 30K/10K divider making 3.75Vout. This is an ADC value of 767 with the 5V reference. What multiplier(s) does it take to recreate the "15V" from the ADC value of 767 with one or two decimal places? Then we would have to break that number into pre-decimal and post-decimal parts to send it to a display.

You are doing great so far. You've go a winner of a program now.
 

techElder

Well-known member
One thing that I did notice is that the "Insert ... into Editor" doesn't quite function. The first time I used it, it inserted about half of the "Command to use:".

My PC uses updated XP. Editor is 5.5.0
 

nick12ab

Senior Member
Version 1.7.1

Version 1.7.1 is a fix for this:
One thing that I did notice is that the "Insert ... into Editor" doesn't quite function. The first time I used it, it inserted about half of the "Command to use:".
The issue was that Windows XP uses a small delay (which is human noticeable if you watch carefully) when switching between windows using the code AND it allows the following code to execute before the window switch completes but Windows 7 does not have this delay so whilst it would work fine on Windows 7, on Windows XP the application would sometimes send the text to itself instead of Programming Editor. The fix was to use a timer set to a short delay to allow for the window switch to complete and now it works fine on Windows XP on a Dothan-core Pentium M. If problems still persist, say so and I'll increase the time delay (currently 50ms). I might have to eventually stick on an options tab where this delay can be changed.

Overview of changes:
  • (Hopefully) fixed problem where text would sometimes not be inserted on Windows XP
  • Fixed bad startup code which would always select the general electronics wizards radiobutton no matter what was saved in the registry

For example, we use 15Vin, 30K/10K divider making 3.75Vout. This is an ADC value of 767 with the 5V reference. What multiplier(s) does it take to recreate the "15V" from the ADC value of 767 with one or two decimal places? Then we would have to break that number into pre-decimal and post-decimal parts to send it to a display.
For 10-bit, the calculation for the ADC value is:
Code:
ADC.Value = Vout.Value / ADCref.Value * 1023
Divide happens before multiply.

Your request should be simple as all I need to do is derive the formula it's even simpler than that. I might be able to get the update completed by today.
 

Attachments

Last edited:

nick12ab

Senior Member
Version 1.8







Added:
  • Added info box to resistor colour code calculator
  • Added hex/dec/bin/oct converter wizard
    • Converts (only) from decimal or hexadecimal
    • Converts to decimal, hexadecimal, binary and octal
  • Added multiplier calculator to ADC wizard
  • Added option to hide entire window border
  • Added a close button for when the window border is hidden
Changes:
  • Default baud rate selection for hsersetup is now 2400 to prevent errors at startup when a low clock speed is saved in the registry
  • Change of layout of resistor colour code calculator
Note: When closing and starting the program in no borders mode, the window border will briefly flash on. I had to have it so that this was done as if I just saved the position as it was without restoring the border, when the program was next run the settings would not be applied properly (yes, I did put the border/no border code before the location code and that did not fix it).
 

Attachments

techElder

Well-known member
Nick, your "multiplier" calculation changes with the "Vin" voltage change. The multiplier should be a fixed number for changes in Vin, but I see your dilemma.

To make this more useful, there should be a multiplier for tenths and hundredths also.

Now that you've added the multiplier, there is still value in having the calculations done with a value of zero for "R1." This is the simplest case for testing the battery voltage, although using "calibadc" is possible, too.

EDIT:

I forgot to add that there is a visual need to have 3 decimal places in the "ADCref+" field.
 

nick12ab

Senior Member
Nick, your "multiplier" calculation changes with the "Vin" voltage change. The multiplier should be a fixed number for changes in Vin, but I see your dilemma.
This probably happens because the ADC value numericupdown actually stores a decimal and when this is put back into the calculation for the multiplier, it would produce a different result from just putting an integer value of ADC Value in to a calculator so I put in integer conversion without fully testing it afterwards. I will take out the integer conversion.

To make this more useful, there should be a multiplier for tenths and hundredths also.
I chose to do thousandths because this gives a reasonable level of accuracy on the PICAXE which can't do decimals.

Or do you mean tenths and hundreds of mV? In that case, that would be a sensible addition.

Now that you've added the multiplier, there is still value in having the calculations done with a value of zero for "R1." This is the simplest case for testing the battery voltage, although using "calibadc" is possible, too.
I'll look at the code later. Calculation of values when R1 is 0 probably doesn't happen because of a division by 0 error.
 

techElder

Well-known member
If this calculation of a multiplier is to be useful to the end user, then it is reasonable to assume that the program should calculate a multiplier that is useful to the end user. The only multipliers that would be useful to the PICAXE programmer would be integers. (Adding a note to that effect doesn't let you off the hook. :) )

This will require more thought on your part. You may have to present the multiplier as a multiply and divide combination to make it useful.

I see the point about the divide by zero problem, and it certainly does apply in the context of a ratiometric voltage division calculator. I suppose the ADC multiplier to real-world numbers is really a function related more to the ADC than the voltage divider.
 

nick12ab

Senior Member
Version 1.8.2

Changes:
  • Added more decimal points to multiplier
  • Impedance calculation now in its own try : catch : end try since a divide by 0 error in this calculation when R1 is 0 would prevent the multiplier from being calculated
I will change to multiplier magnitude selection rather than decimal places when I have more time to do this.
 

Attachments

Buzby

Senior Member
Hi Nick,

I'm finding the calculator very useful, it's a great piece of work.
( And it's getting better by the minute !. You uploaded 1.8.3 as I was typing this reply to 1.8.2 )

One thing it needs is it's version number somewhere on show.
This should not be too difficult to implement.

Cheers,

Buzby
 

nick12ab

Senior Member
Version 1.8.4

Hi Nick,

I'm finding the calculator very useful, it's a great piece of work.
( And it's getting better by the minute !. You uploaded 1.8.3 as I was typing this reply to 1.8.2 )

One thing it needs is it's version number somewhere on show.
This should not be too difficult to implement.

Cheers,

Buzby
Easy - I'll just stick it in the title bar. As, like the text "PICAXE Command Calculator", you don't need to see this all the time, I don't think it really needs its own dedicated label on the form but say so if you think different.
 

Attachments

nick12ab

Senior Member
Version 1.9



Changes:
  • Compsetup command now supports all PICAXEs which support the command rather than just 28X2/40X2/28X2-3V/40X2-3V.
Please confirm that everything works OK, and keep the suggestions coming.
 

Attachments

techElder

Well-known member
Nick, the multiplier function in the potential divider section is really not right, if not wrong. I don't know how to explain any further.
 

nick12ab

Senior Member
Version 1.9.1

Changes:
  • Fixed horizontal alignment of 'hint1' label on hintsetup wizard
Yes, that's it. A label being moved by one pixel. Things like labels being out by a pixel does irritate me.

@TexasClodHopper - Yes you do need to explain further or at least recap me on what you wanted and how the previous update failed to deliver this so that I can make the application better.
 

Attachments

techElder

Well-known member
Nick, here is a "checkBattery" routine that I am using. It isn't exactly linear, but I ran out of time researching the "correct" way to do this and just adjusted the numbers until I got it right at 12VDC and close enough at 15VDC and 11VDC.

The problem on the forum when this question is brought up is that, just like elbows, everyone has one; solutions, that is. One would think that in programming a PICAXE something like this would be locked down tight. While reading everything I could here, there is no simple consensus on measuring voltage of the battery with a voltage divider and an internal voltage reference. (Even just writing the sentence that I just wrote will invoke some posts on "how I do it", but there still will be no consensus.)

My little "checkBattery" routine operates off of a voltage divider of 1/4th (30K in series with 10K). A voltage of 15VDC is divided down to 3.75VDC. I used 1% resistors. I used the 4.096VDC reference (fvrsetup FVR4096 with adcconfig %011). I used a word variable for "adcBatteryreading", "batteryVoltage" and "batteryLow" are byte variables and "BATVOLTMIN" is a constant.

The byte calculated is 10 times the battery voltage. That gives me the integer representation of the first digit after the decimal point. I don't care about any greater resolution. (Other solutions will care about greater resolutions.)

What more can I say? I've finished version 1 of my project and am starting to optimize the design for version 2. Perhaps you can be famous and come up with a total solution.

Code:
checkBattery:		'Compares battery voltage at divider to fixed minimum; sets flag

	batteryLow = 0
	
	readadc10 ADCBAT, adcBatteryreading
	
	
	' "40" = 4 for the voltage divider and 10 to scale the factor to an integer
	' "273" = 1024 divided by 3.75 (15v / 4) rounded to scale it to an integer
	
	batteryVoltage = adcBatteryreading * 40 / 236 ' adjusted from 273 to read correctly at 12.0 v.

	if batteryVoltage < BATVOLTMIN AND batteryVoltage > 50 then	' 50 = 5 volts

		batteryLow = batteryVoltage	' this can be used as a previous voltage value

	else

		batteryLow = 0

	endif	

	return
 
Last edited:
Top