PDA

View Full Version : 12f629 vs ATtiny 11L



AMay
- 8th March 2009, 05:52
I saw an article in Nuts & Volts about a voltage booster to power an led flashlight. The oscillator was an ATtiny 11L chip programmed off and on, with a 4mHz internal clock. The article indicated that it would provide a pulse as fast as about 100 kHz. (On 7 us, off 2-3 instructions, 1 us each.)

So I figured why not try the same circuit using a 12F629, which also has a 4mHz internal clock, programmed the same way. The data sheet (section 10) suggests that each instruction should take about 1 us. Should work the same.

No dice, the fastest pulse I can get is about 10 kHz, pretty much square. I wrote the program in PIC basic, but I checked the assembler file, and I think it is as simple as possible. I am using pin 0, high and low (no pauses) and loop. (Yes, I disabled the comparator.)

There has got to be a way. Maybe?

Thoughts and guidance appreciated.

A May

Acetronics2
- 8th March 2009, 09:45
Hi,

What about a sooooo .... classical MC 34063 from Freescale ... ??? ... or an UC3842 ???

Alain

Bruce
- 8th March 2009, 15:28
@ DEVICE MCLR_OFF, INTRC_OSC, WDT_OFF, BOD_ON, PWRT_ON, PROTECT_OFF

DEFINE OSCCAL_1K 1 ' calibrate internal osc

CMCON = 7
GPIO = 0
TRISIO = 0

Main:
GPIO.0 = 1 ; 1uS ON
@ GOTO $+1 ; 2uS ||
@ GOTO $+1 ; 2uS ||
@ GOTO $+1 ; 2uS ||
GPIO.0 = 0 ; 1uS OFF
GOTO Main ; 2uS || (10uS total)
That should give you around 100kHz with 7uS ON with 3uS OFF.

AMay
- 8th March 2009, 21:11
Alain - I don't know those chips. I admit only to a modest understanding of PICs and PIC basic. I have programmers for only PICs and Basic Stamp I's. Additional programmers look expensive for satisfying my curiosity.

AMay
- 8th March 2009, 21:16
You are too advanced for me, I don't recognize the code. I know PIC Basic some, and a little assembler. Up to now, that has been more than enough. But you are giving me hope.

A May

Bruce
- 8th March 2009, 21:27
This isn't anything very advanced. @ GOTO $+1 is just a simple assembler instruction
telling it to goto here (which is the current instructions address) +1, which is just the
next instructions address.

This just eats two instruction cycles, and gives you the required delay time in instruction
cycles to generate the frequency you were looking for.

The graphic attachment is just an MPLAB logic analyzer screen capture to show you the
actual timing on the output pin.

You could do the same thing with just a few @ NOP instructions between the GPIO.0 = 1
and GPIO.0 = 0.

It's really simple stuff.

tenaja
- 8th March 2009, 21:30
You are too advanced for me, I don't recognize the code. I know PIC Basic some, and a little assembler. ...

This (see quote above) is why you thought the code was as tight as possible, yet you were only getting 10kHz. PBP is extremely inefficient. It is very simple and very nearly idiot-proof, but most certainly not the compiler to use if you are trying to get tight, fast running code.

Bruce
- 8th March 2009, 21:44
Hi Cliff,


PBP is extremely inefficient.
Sorry, but I don't agree with that statement. PBP is quite efficient, and one of the least
buggy BASIC compilers out there.

It may not produce the tightest code for a BASIC compiler, but it's for sure one of the
most reliable, and it's very simple to include just a few lines of assembly code when you
need tight timing like this.


but most certainly not the compiler to use if you are trying to get tight, fast running code.

What BASIC compiler would you recommend & why?

If you know of a PIC BASIC compiler that's more reliable & efficient than PBP, I would
love to see your test results...;o}

languer
- 9th March 2009, 07:05
Chuck Hellebuyck wrote a cool article on Nuts & Volts Magazine (April 2007, and June 2007). It did a quick comparison between different compilers, and I have to say was very surprised. PicBasic Pro fared extremely well.

AMay
- 11th March 2009, 20:14
While I still have trouble with Bruce's code, I went back to the PIC data sheet, and tried the following code which delivers 113Khz, and the circuit delivers 15.2 volts out to 5 high bright LEDs. 4.5v in at 80ma. The LEDs are quite bright.

From Microcode studio, using PIC Basic (not Pro.)

Settings:
poke $19, $7 'Disable comparators
low 0
ASM
LOOP
BSF 005H,0 ;set bit 0, Pin 0 high
NOP ; kill time, 1us
NOP
NOP
NOP
NOP
CLRF 005H,0 ;clear bit 0
GOTO LOOP
ENDASM

tenaja
- 19th March 2009, 15:37
Chuck Hellebuyck wrote a cool article on Nuts & Volts Magazine (April 2007, and June 2007). It did a quick comparison between different compilers, and I have to say was very surprised. PicBasic Pro fared extremely well.

I would venture to guess that the biggest reason it did so well is because NV refuses to accept articles which contain the Proton compiler. If you eliminate the most competent alternatives, it is easy to say you are the best. And yes, I own both compilers.

languer
- 19th March 2009, 20:03
I would venture to guess that the biggest reason it did so well is because NV refuses to accept articles which contain the Proton compiler. If you eliminate the most competent alternatives, it is easy to say you are the best. And yes, I own both compilers.
This may be true. I have no evidence to prove or disprove this. I do want to make a disclaimer, I am not a PBP or Proton guy. I do own an old version of PBP but have not used it in a long while. I have used C for a long, long time now.

Regardless, after the initial article Chuck did get quite a bit of information from different camps (including myself from the C camp). And the reason I said I was quite surprised, was that for this test (and the test was quite simple - so one should not read too much into this) Proton and PBP achieved the same speed, as well as CCS C. And HiTech C was only slightly faster.

I believe the memory usage was better for the C compilers, but cannot say for sure without revisiting the articles and e-mail conversations.

Most important thing is that beauty is in the eye of the beholder, and what works for one may not work for the other.