Conversion to compiler

RobertN

Member
May have asked this before.

Have this program running on a 08M that is too slow. There is only 3 I/O so a Pic 10 or 12 is all it needs.

What is the most pain free way for an old geezer to convert this program into a compiled language? Have to stay with basic, no good with foreign languages. Have a Pickit2 starter kit.

Would it be reasonable to contract this out?

Any suggestions appreciated.
 

womai

Senior Member
If you post the code and an explanation what it does (or is supposed to do) I'd be willing to have a look; if it's not too difficult I can convert it for you and burn you a device. I have a PIC development board and a C compiler at hand, as well as a few 12F683's (which 08M is based on) in my drawer, and have converted a few Picaxe programs for myself already. Usually it's pretty straightforward except for a few Picaxe specific commands.

If you need only a single piece I'll do it for fun and won't charge anything. For larger quantities we'd need to discuss.

That said, if the forum members can have a look at the code maybe we can even figure out how to speed it up without leaving the Picaxe realm...
 
Last edited:

westaust55

Moderator
You do not give much information to work with.

What does "too slow" really mean?
How much faster (x times) do you need to operate?

Before you go to compilers, have you considered increasing the 08M speed from 4MHz to 8MHz?
If not so far, then have a look at the PICAXE manual 2 (V6.9) page 185 at the SETFREQ command.
Add the line
SETFREQ m8
at the start of your code.

As Womai suggests, post your code. Someone may be able to point out how to improve the speed slightly through changing the BASIC code structure.
 

MartinM57

Moderator
Would it be reasonable to contract this out?.
Again, not much info to go on, but before all that complexity I'd investigate by spending GBP3.50 on a 20X2 and run it with "SETFREQ m64". The fact that there would be a few unused pins wouldn't keep me awake at night...
 

RobertN

Member
The program is one ~100 byte loop, cycling through as fast and consistently as possible. It needs a fast loop speed to catch the input pulse edges and for good input period resolution.
At 8 meg Hz. a 08M cycles through about 137 times a second, this is at least an order of magnitude to slow. Refining an interpreted program is not likely to obtain the required speed. A 20X2 would run 8 times faster, still short of resolution for the 12.5 ms input period.
For reasonable measurement resolution of the input pulses, the program would have to cycle time of <250us. That leaves an assembler or a compiled language that may, or may not be fast enough.

Womai, Appreciate your offer. Like any program, there will be an unknown number of changes. Something would have to be worked out.
 

womai

Senior Member
Actually, a 20X2 at 64 MHz is only 4 - 6 times faster than a 08M at 8 MHz (more interpreter overhead). But if you want to capture pulses, maybe the pulsin command could work? That has a resolution of 10us at 4 MHz, 5us at 8 MHz. Again, if you could post your code (or PM it to me if for some reason you don't want to make it public) I would have to guess less and could help better.

Yet another option would be a X2 Picaxe using the hardware interrupt. These interrupts are edge sensitive (rising or falling, which is programmable), as opposed to the "classic" Picaxe polled interrupts which are level sensitive (high or low). Look up the commands hintsetup and setintflags for details. Such an interrupt in combination with the hardware timer (running in the background, to "time stamp" the edge when the interrupt occurs) could have sufficient resolution, although tight coding will be mandatory - 250us is just about 5 commands on a 20X2 at 64 MHz.

With a compiled program a reaction time of 250us is easy to achieve - that's 125 assembler commands at 8 MHz (and could be sped up further because the 10F683 can use an external resonator up to 20 MHz instead of the internal oscillator). Just send me your code and I should be able to get a decent estimate (execution time, not money :) within a day. As for changes, I really don't mind playing around with this a bit.

Wolfgang
 
Last edited:
Top