Page 1 of 1

LED blink - Real time and Quartz Configuration

Posted: Sun Jun 29, 2008 8:01 am
by carbon9
Hi all,

First of all thanks to L. Kerhuel for this very useful blockset. I've installed it succesfully referencing to the animation on the web site. Also, I applied the sinusoidal motor driving example. The blockset compiles succesfully.

So, going one step further, I tried to compile a new project. The aim is simple:

1. Blink a LED connected to Port F.2 infinitely using a pulse on Simulink
2. Drive a LED on Port D.2 if Port B.2 is made logic 1.

The copy of my simulink file is attached to this message.

I've sucessfully compiled the project and generated .hex file. I'm using BigdsPIC board with 30F6014A from Mikroe, I've downloaded the hex file on the board using Mikroe's download program. The program works.

1. The LED on F.2 blinks with a period of about 0.4 sec
2. The LED on D.2 is ON if B.1 is made logic 1.

But, my question is: I want to blink the LED on F.2 with 2 sec period. What can I adjust to make the period to 2 sec with 50% duty cycle?

Regards

Re: LED blink example question

Posted: Sun Jun 29, 2008 11:30 am
by LubinKerhuel
Hi carbon9,

Few comments about the model:

A simulation of the model shows that the led should be blinking at a rate of 1Hz (duty cycle of 0.5s).
You do not get 1Hz because your quartz configuration (master block dialog box) may not be configured correctly (i.e. information provided to the simulink model are not conform to the material information).
From your model configuration, the Quartz of the board should is : 2.5*4 = 10Mhz. This may be false.
(See help of the Master Block on the website. I just updated it)

I post a model with few comments:

- Configure appropriate Quartz in Master block!
- Use Color Sample time from the Format menu
- Replace Pulse generator with a counter with a rate of 1 Hz (run simulation with simulink to check results)
- Set Digital Input with a sampling rate of 1ms to get a more reactive result (base time step of the model, menu Simulation / Configuration Parameters / Solver)

Lubin

Re: LED blink example question

Posted: Tue Jul 01, 2008 6:39 am
by carbon9
Thank you very much for your comments.

Another question is: can we drive an LCD using the Simulink blockset?

Regards

Re: LED blink example question

Posted: Tue Jul 01, 2008 7:22 am
by LubinKerhuel
It is probably possible to drive an LCD. What is the interface of the LCD ?
If you have to create a complexe sequential logic, you could also use stateflow.

In the worst case, use the "C Call function block" to write the driver for the LCD.
( only available in the registred version of the blockset)

Re: LED blink - Real time and Quartz Configuration

Posted: Tue Jul 01, 2008 6:46 pm
by carbon9
Thanks for the replies. I'll try and if works, will post on this forum.

Regards