Extra PICAXE Wizards

techElder

Well-known member
#81
Nick, are there any plans to extend the BITMAP TABLE calculator to it's current limit of 8-bits to 16-bits? The 8-bit allows for an easy workaround if you are going to stop there, but I am curious.

The calculator is working great and has let me explore some patterns that I hadn't really thought about.

THANKS!!
 

nick12ab

Senior Member
#82
Nick, are there any plans to extend the BITMAP TABLE calculator to it's current limit of 8-bits to 16-bits? The 8-bit allows for an easy workaround if you are going to stop there, but I am curious.
The table command only supports data as bytes and not words, so no.

If I can think of something that will separate the word into two bytes really easily away from the computer (thanks to the great revelation from Ray) then I might do it.
Very fine piece of VB... congrats. You do realize that if you are not presently wearing eyeglasses that you will be soon?
On the other hand, keep the suggestions for new wizards coming and I'll consider them.
 

techElder

Well-known member
#85
Sorry, I had a brain eruption. Too many things going on at once.

READTABLE supports the reading of WORDs from TABLE in Little Endian format.

So, I'm reading 16-bit WORDs that I want to put in the TABLE with your calculator.

I hope I can quit misleading you soon! <GRIN>
 

techElder

Well-known member
#86
Back To Bitmap Wizard

1. Relating to Options/Dragging copies first bit instead of toggling: Actually, this functionality toggles first and then allows dragging to copy first bit. Probably not what is expected; at least by me.

2. Relating to Tool Tips: These tips are quite long, presented as one long line on the screen and time out before one can finish reading them.
 

nick12ab

Senior Member
#87
Version 1.10.4

Added:
  • More tooltips
Changes:
  • Doubled tooltip disappear timeout
  • Changed long tooltips into multi line tooltips
  • Renamed that checkbox in the bitmap wizard
[hr][/hr]
READTABLE supports the reading of WORDs from TABLE in Little Endian format.
So do you mean that if you use
Code:
readtable word 1,(w0)
then b0 will become whatever is at location 2 of the table and b1 will become whatever's at location 3 of the table?
 

Attachments

techElder

Well-known member
#90
Gettin' old and can't remember things very long. This is the third item that I couldn't think of before:

3. Relating to the "Start" value for Table data: Once the user has determined a location ("start") value for the table data represented on the graph, you know what address to suggest next because you have the number of columns also.

So if the user lets the first location be "0" then creates 16 columns, you know that the next "start" address to suggest is "16".

Of course, the user can override this easily with the magnificently programmed interface that you provide. ;)
 

nick12ab

Senior Member
#91
3. Relating to the "Start" value for Table data: Once the user has determined a location ("start") value for the table data represented on the graph, you know what address to suggest next because you have the number of columns also.

So if the user lets the first location be "0" then creates 16 columns, you know that the next "start" address to suggest is "16".

Of course, the user can override this easily with the magnificently programmed interface that you provide. ;)
The big problem now is where am I going to fit in the option to enable/disable this? There's currently two possibilities:
  1. Nag the user with a message box which appears each time the 'Insert command into the PICAXE Editor' button is pressed asking whether they want to clear the data and increase the start address by however many columns there were
  2. Add an item to the 'More' menu (with checkbox function enabled, VB natively supports this) which will be called "Multi-command mode" or similar with an explanatory tooltip
 

techElder

Well-known member
#92
Would it be a valid assumption that the user would be creating a series of Table data statements?

If so, then just quietly put the next location in that box.
 

techElder

Well-known member
#97
Just observing my own experience with it.

Now, I would expect to see some differences with a calculated value and real world conditions. Understood. However, I don't expect a calculator to differ from itself. To me, it's an indication of a problem that I would investigate.

For instance, in your potential divider input these values:
  • Vin = 15.00
  • R1 = 30,000
  • R2 = 10,000
  • ADCref+ = 5.00
"Multiplier" comes out to be 20 and "ADC value" comes out as 767. Multiply the two together, and you get 15,340. Shouldn't it be 15,000 since that's what we started with?


Also, perhaps it doesn't matter to the calculation, but shouldn't the user be able to input a 3 digit reference value? It's a bit disconcerting to have a reference value rounded up in a calculator. RevEd shows all reference values in the ADC as 3 digit decimal values such as "4.096".
 

nick12ab

Senior Member
#98
"Multiplier" comes out to be 20 and "ADC value" comes out as 767. Multiply the two together, and you get 15,340. Shouldn't it be 15,000 since that's what we started with?
It did that because you previously insisted that decimals are useless as the PICAXE can only do integers. If you use the combobox then you can get better precision. I might just stick the decimals back in as it's obvious that neither are right but having the decimals would be better.
 
Nick, you are showing a lack of understanding of the problem at hand. It has nothing to do with decimals, picaxe or me.
Yes it does. Change the setting from "Multiplier to get Vin*10^-3" to "Multiplier to get Vin*10^-9" and the multiplier shown is 19550342 which when multiplied by 767 gives a more accurate Vin of 14.995112314V (14995112314*10^-9).
 

hippy

Technical Support
Staff member
"Multiplier" comes out to be 20 and "ADC value" comes out as 767. Multiply the two together, and you get 15,340. Shouldn't it be 15,000 since that's what we started with?
Isn't this an issue of forgetting the divide by 1023 ?

767 is the value which will be read when 15V is applied to the divider input -

Nadc = (15/4) * 1023 / 5 = 767.25 = 767

A 20V input to the divider will generate a maximum Nadc of 1023 so the multiplier to recover 20 will be 20 (5*4) -

Vin = ( Nadc * 5 * 4 ) / 1023

If we drop 767 into that we get 14.99 etc.
 

techElder

Well-known member
I don't know. It's supposed to be a calculator that does all that for the user.

Nick is averse to anything I bring up now, so I won't be bringing up anything else.
 
Quantization Error: http://ww1.microchip.com/downloads/en/devicedoc/adc.pdf

By definition, digital numbers are non-fractional whole numbers. In many cases, the high and low voltage references are selected as the microcontroller supply voltage and ground, at other times an external reference or references are used. The output of an analog-to-digital converter is a quantized representation of the original analog signal. The term quantization refers to subdividing a range into small but measurable increments. The total allowable input range is divided into a finite number of regions with a fixed increment.

Reference (internal) voltages: http://embedded-lab.com/blog/?p=3045
Why the reference voltages are 1.024, 2.048, or 4.096 V?

The reason for the reference voltage to be non-integer numbers like these is to provide a precise resolution in A/D conversion. For example, if the positive A/D reference is 2.048 V and the negative reference is 0 V, then the resolution of 10-bit A/D conversion is 2.048 V/ 1024 = 2 mV/Count. This means, in order to get the analog value (in mV) back from the digital count, you just need to multiply the count by 2. Similarly, the positive reference voltage of 4.096 V gives the conversion resolution of 4 mV/Count. This makes the calculations easier and accurate.

Therefore, if we are dealing with 5.000V as the reference voltage, there is really no way to come back to exactly 5.000V. There is always uncertainty in the ADC process because
The process of quantization has the potential to introduce an inaccuracy known as quantization error, which can be viewed as being similar to a rounding error. (And) It should be noted that the minimum quantization error for the analog-to-digital converter peripheral in the PICmicro devices is 500 micro volts. Therefore, the smallest step size for each state cannot be less than one milli-volt.

- Ray
Quantization.jpg
 
Last edited:
I don't know. It's supposed to be a calculator that does all that for the user.
Nick is averse to anything I bring up now, so I won't be bringing up anything else.
@Tch... Having written more tools for IT Ops than I could possibly count back in my professional career, the desire for enhancements never stop. IT folks usually call this 'scope creep' ... or, the ever-evolving feature set. Sometimes, I just had to draw the line because I had other things to do. Often, after a while, I would come back and rework a section to allow for enhancements. Sometimes, I just never came back because the initial design and implementation were not flexible and would always cause me frustration... kind of the idea "if it works, don't fix it...".

- Ray
 

techElder

Well-known member
My suggestion for this calculator wizard has nothing to do with "quantization" errors. That kind of error comes from the hardware.

My suggestion also has nothing to do with mission creep. The calculator isn't right as it stands, and I was trying to help Nick with my suggestions.

Perhaps I've overstayed my welcome, and someone else needs to step up and get involved.
 

hippy

Technical Support
Staff member
For example, if the positive A/D reference is 2.048 V and the negative reference is 0 V, then the resolution of 10-bit A/D conversion is 2.048 V/ 1024 = 2 mV/Count. This means, in order to get the analog value (in mV) back from the digital count, you just need to multiply the count by 2.
I've never been entirely convinced of that.

Let's look at a 2-bit ADC. That's got 4 steps giving four values 0 to 3, and with 2mV per step that's a Vref of 8mV ( 2048mV for 10-bit divided by 256 giving 8mV for 2-bit confirms that ).

Looking at the input voltages ...

0mV-2mV gives a result of 0
2mV-4mV gives a result of 1
4mV-6mV gives a result of 2
6mV-8mV gives a result of 3

All fine so far, but you don't get the actual input voltage when you multiply the result by 2, you actually get the lowest input voltage which can produce that result.

A more accurate assessment of the actual input voltage is achieved by multiplying by 2 and adding 1 ( half the step value ). The problem then is that a reading of 0 never equates to 0mV. So we're stuck that we have a choice of an equal error at both ends or a larger error at the top.

The real problem is that, while there are 1024 values and steps in total, there are only 1023 steps between a 0 and 1023 result. Converting from voltage to value is fine, but it's not so good when going back the other way.
 
U
I've never been entirely convinced of that.

Let's look at a 2-bit ADC. That's got 4 steps giving four values 0 to 3, and with 2mV per step that's a Vref of 8mV ( 2048mV for 10-bit divided by 256 giving 8mV for 2-bit confirms that ).

Looking at the input voltages ...

0mV-2mV gives a result of 0
2mV-4mV gives a result of 1
4mV-6mV gives a result of 2
6mV-8mV gives a result of 3

All fine so far, but you don't get the actual input voltage when you multiply the result by 2, you actually get the lowest input voltage which can produce that result.

A more accurate assessment of the actual input voltage is achieved by multiplying by 2 and adding 1 ( half the step value ). The problem then is that a reading of 0 never equates to 0mV. So we're stuck that we have a choice of an equal error at both ends or a larger error at the top.

The real problem is that, while there are 1024 values and steps in total, there are only 1023 steps between a 0 and 1023 result. Converting from voltage to value is fine, but it's not so good when going back the other way.
@Hippy: I think Microchip may over simplify the sequential nature of their SAR ADC. Maxim's explanation actually makes more architectural sense to me: http://www.maxim-ic.com/app-notes/index.mvp/id/1080
The analog input voltage (V IN ) is held on a track/hold. To implement the binary search algorithm, the N-bit register is first set to midscale (that is, 100... .00, where the MSB is set to 1). This forces the DAC output (V DAC ) to be V REF /2, where V REF is the reference voltage provided to the ADC. A comparison is then performed to determine if V IN is less than, or greater than, V DAC . If V IN is greater than V DAC , the comparator output is a logic high, or 1, and the MSB of the N-bit register remains at 1. Conversely, if V IN is less than V DAC , the comparator output is a logic low and the MSB of the register is cleared to logic 0. The SAR control logic then moves to the next bit down, forces that bit high, and does another comparison. The sequence continues all the way down to the LSB. Once this is done, the conversion is complete and the N-bit digital word is available in the register.
Yes, somewhere/how we must deal with those two 1/2 bit values in going in reverse. The choice will logically be made in table lookups. Or, it could be done in formula math, if needed. If I am dealing with temperatures such as engine-head or exhaust, I'm going to want the hotter temp (high value plus 0.5 before conversion) but if I am measuring potential to freeze, I would opt for the lower temperature in math or table lookup. One just needs to be aware of those two half-bit LSB ADC values.

- Ray

@TCH, my apologies ... no criticisms were meant, only a suggestion that nick may be a exhausted due to the pace of recent revisions. My bringing up how the ADC generates its value was to explain why even if PICAXE is integer, the ADC unit works with charge increments of microvolts.., fractional parts of a volt.
 
Last edited:
Can someone clarify which calculation should be used for the ADC value? Hippy's specified that Vin is calculated using Vin = ( Nadc * 5 * 4 ) / 1023 - again, is this definate?

Any more suggestions?
 
Can someone clarify which calculation should be used for the ADC value? Hippy's specified that Vin is calculated using Vin = ( Nadc * 5 * 4 ) / 1023 - again, is this definate?

Any more suggestions?
I've been waiting for Hippy, too. From the references I listed in #103, I would assume that the minimum voltage resolution is Vref / 2^AD_bits = 5 / 256 or 5 / 1024 by default for 8_bit and 10_bit resolutions. If using the precision internal references, then 5 is substituted with 4.096 / 2.048 / 1.024 as appropriate. However; please wait for confirmation from others. The step size voltage then becomes the minimum voltage resolution from the equation and the full-scale reading for the AD becomes (2^AD_bits - 1) * V_step. The mean resolution uncertainty is 1/2 bit of resolution.

Therefore, if using 10-bit AD and using the internal 2.048 reference, 2.048 / 2^10 = 2.048/1024 = 2mV per step (with 1/2 bit uncertainty.) The maximum full-scale AD output would be 2.048 - 2mV which is the same as saying (2^10 - 1) * 2mV.

- Ray
 
Hi Nick and all,
Nick thanks for the picaxe calc, sure I will find it useful. It should be part of the programming editor, in stead of the normal windows calc, which is there at present.
I too wish that Macaxe was more like the programming editor, but its fairly basic with no simulator, and missing a few bells and whistles...

The truth is I hate windows with a passion!! (Especially 7, use XP) it cost too much, is insecure it's a load of various coding glued together, is ineffective, slow, etc, etc... But I have to use it for things like Diptrace and Programming editor, etc. So I have it dual booted on my iMac, yes the mac is a bit pricey (Even S/H like mine was on eBay) and I sure don't have money to waste, but I don't get silly bubbles poping up all the time telling me it's hiding my iunused cons, or some other irelivent item. Mac OS cost about £25 and you don't even have to activate it or register it. As it's based on Unix/Linux it just gets on with the job, tells you what updates are available and give you the option to do as you wish.

I will not get of my soapbox and return to normal, whatever that might be...

Once again Nick I would like to see the neat little pic editor add-on be part of it.... come on Rev-ed!!

Regards
Mel.
 
Nick thanks for the picaxe calc, sure I will find it useful. It should be part of the programming editor, in stead of the normal windows calc, which is there at present.
This is under Rev-Ed's control as they don't release the source code.

The truth is I hate windows with a passion!! (Especially 7, use XP)
And now for every action there must be a reaction!....

But you don't pay for service packs (Apple charges for Mac OS equivalent). In addition, most people don't buy new computers more often than new versions of Windows come out and they can buy the OEM version of Windows which is far cheaper than retail Windows. (The OEM version can't be used with another computer once activated on one computer but the retail one can)

Yeah...
ADDED: Funny quote:
I think statements about the security of mac are akin to quoting the crime rate in Antarctica.
it's a load of various coding glued together
All right then - use drivers made by the OS maker rather than the hardware makers themselves because everybody knows that third parties are better at writing drivers than the hardware makers themselves(!) (sarcasm)

In what way? (Use FilterKeys to prevent accidental double spacing)

In what way? Have you actually installed all the drivers, and used Windows Update? Just an example - ATI graphics cards perform very poorly until you install the drivers for them but in the case of an iMac you won't be able to have any dedicated graphics cards of any sort.

So I have it dual booted on my iMac
Perhaps 'Bootcamp' or whatever it is deliberately slows down Windows to convice Mac users that their next computer should be a Mac. But that's unlikely. If Windows is slow on the Mac then it's probably because it isn't set up properly. On that topic, Mac OS wouldn't 'just work' if you attempted to install it on a Pentium III computer.

yes the mac is a bit pricey
Great. That at least makes up for the price of Windows. (in 5 years' time) Now let's add some high performance low latency DDR3 RAM with massive heatsinks and a watercooling system for everything and overclock it to extend its useful life Can't do that. That's one more point for non-Mac PCs (not necessarily Windows ones). Link: Mac Upgrade

Mac OS cost about £25
...per minor version update.

you don't even have to activate it or register it.
If that's such a great thing then does that mean that you encourage piracy?

As it's based on Unix/Linux
So why not just use Linux and then it really is completely free!

it just gets on with the job
It allows Apple to claim that it's open source. Which it is to some limited extent.

tells you what updates are available and give you the option to do as you wish.
Just like Windows and Linux.

I will not get of my soapbox and return to normal
I will get off mine when you get off yours.

P.S. My Mac-bashing post looks a lot longer than your Windows bashing post mostly because of the extra room your quotes take up, but my post is longer anyway. But I was going to use code tags to stick it in a small scrollable subpage but the forum then ruins the formatting of the quotes.
 
Ok Nick point taken, pull your claws back in! I must have built many PC's in the past (good and bad), and yes I have used Linux (Mint 11). Can't agree with all your comments, so let agree to differ, that might be best for all of us, we could start an OS battle, but that's not what this forum is about.
Just to repeat, thanks for a useful bit of software, I never really tried VB, the only thing I did was a bit of Pascal back in the Z80 days.
Regards
Mel.
 
Version 1.11

This update is to address the two main issues with the bitmap wizard which are...
  • No way to save or import data - what if you have to create another bitmap using the wizard - you can't without losing the current one!
  • No way to insert or remove a column - you'd normally have to shift all the data manually bit by bit if you wanted to do this.
This update addresses both these issues with a new import function!



It is compatible with table, eeprom and lookup commands and accepts the command (e.g. table 0,($FF,$EE)) with no modification and automatically determines the correct number of columns and (for lookup) number of bits too.

It is a bit limited as the data array must be in hexadecimal and the start address (for table/eeprom) must be in decimal. Also, I haven't programmed much syntax checking into it so most syntax errors (such as leaving out the start address) will result in data being missing, data being used as the address or lookup variable, etc. rather than an error message. However it should work fine with correct syntax.

"How does it allow you to insert or remove columns?" - simply copy and paste the Command to use from the wizard into the import dialog's textbox and remove unwanted values to delete columns and insert zero values wherever you want to to insert blank columns.

Some other changes:
  • Drop down menus now show on their buttons' Click events rather than MouseDown so that the menus can be opened with the keyboard
  • Fixed 'issue' (lack of code, actually) where if the automatic minimize to system tray option is enabled then the window must be re-shown using the tray icon after an error message is shown
Comments?
 

Attachments

Version 1.11.1

This minor update fixes the following niggles with the bitmap wizard:
  • Import of long command would take a long time if the form is visible as the editing area gets redrawn every time a new word is added to the array from the import string
  • Importing a command where the maximum number of words/bytes supported by the command are used would cause an error message to appear but all the data would still be present (but the error would be annoying and the destination variable would be missing in the case of a lookup command)
  • The Info box still referred to the columns being controlled by + and - buttons and had no mention of the import function
  • The NumericUpDown controls in the Options groupbox weren't positioned very well
Other general niggles fixed:
  • PICAXE-specific/other wizards selection radio buttons now in their own panel so that they can be selected with the tab key and changed with the arrow keys
  • Form is now activated after clicking on the system tray icon
Added:
  • System tray icon now has context menu that allows the wizard to be closed or the last inserted command to be inserted again into the PICAXE editor without having to open up the (hidden) wizard
 

Attachments

Version 1.12.1



Added:
  • Button to extend/restore size of bitmap area in bitmap wizard
Changes
  • Fixed problem where hsersetup or settimer wizards would display incorrect command to use at startup
  • Added reminder for setintflags command in infobox for hintsetup command
 

Attachments

Version 1.12.2

Some new minor updates!

Changes
  • Fixed problem where hsersetup or settimer wizards would display incorrect command to use at startup
This was not correctly correctd as for hsersetup the wrong NumericUpDown control was specified in the code used to correct the issue so it set the clock speed to 2400kHz instead of the baud rate to 2400 at starup. That has now been corrected.

The issue where the bitmap area for the bitmap wizard flickers has also been corrected by creating a new double buffered panel class (because on the normal panel the property is 'protected') and that seems to work fine. Please do comment if doing that has created a performance or other issue.
 

Attachments

Version 1.13





Added:
  • Bitmap wizard now has the ability to import and create C-style arrays (e.g. Arduino) supporting up to 16 bits. This can be used to 'convert' an Arduino array to a PICAXE one.
  • Bitmap wizard now has an option to reverse the bits in the bitmap which works for all three amounts of bits that can be selected (8/12/16) which can be used when the PICAXE program requires that the most significant bit is at the top.
  • The 0x prefix for hexadecimal numbers is now supported in addition to $ when importing any command into the bitmap wizard. The 0x prefix is used when creating C-style arrays and the $ prefix for PICAXE commands but either prefix is acceptable when importing a command.
 

Attachments

Last edited:
Top