Simple Oscillator

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
EddieB
Posts: 55
Joined: Tue Jan 30, 2007 7:17 pm
Contact:

Simple Oscillator

Post by EddieB »

Hello there,

Ive spent the last couple of hours tinkering and playing with my new programmer... Now, I was wondering if I could make a simple oscillator with my development board, There are some timer options in the chip setup, but I dont really know how to use them... I can make an oscillator with a few capacitors etc, but I was hoping there could be an easier way... Also, at the moment... Im using a while loop with flowcode and turning the data pin on and off with a 200 ms delay.

Cheers

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Post by Mark »

Hi Eddie,

You already have made an oscillator, flasing an LED is just that, the knight rider effect programme is effectively a port full of oscillators. Just vary the delays to make any oscillator speed you want up until (about) clock speed/4/4 which is probably around 1MHz.

That is the beauty of PIC's over conventional analogue electronics, all the varying of resistors and capacitors goes out of the window. :D

Could I suggest looking at the Flowcode tutorials in the learning centre. Working through these will take you a long way to understanding the benefits of E-blocks/Flowcode. :)

Mark
Go with the Flow.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

For a shorter delay you can use a C code block with the following command

Code: Select all

delay_10us(FCV_VAR1);
then set up a variable in flowcode called var1 and give it a value. The C code block will then delay the value in the variable x 10 micro seconds.

EddieB
Posts: 55
Joined: Tue Jan 30, 2007 7:17 pm
Contact:

Post by EddieB »

Hello,

I was playing with my new programmer all last night and was making simple flowcharts for things like this:

Start
|
While 1
Output Port B 1
delay 1 sec
Output Port B 0
EndWhile
|
End

Although it doesn't have the desired affect....

Cheers

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

More than likely this is a configuration word setting problem. Make sure the config settings are appropriate for your hardware (especially the oscillator settings) and that the clock speed setting is correct.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Post by Mark »

Eddie,

You need two delays.

In your loop you have the LED out for about 10us or 0.00001 seconds, and on for 1 second.

Start
|
While 1
Output Port B 1
delay 1 sec
Output Port B 0
delay 1 sec <--------------- :D
EndWhile
|
End
Go with the Flow.

EddieB
Posts: 55
Joined: Tue Jan 30, 2007 7:17 pm
Contact:

Post by EddieB »

Ah Thankyou!

Cheers

Post Reply