LED blink - Real time and Quartz Configuration

Create new topics, add your comment, remark, bugs...
Post Reply
carbon9
Posts: 3
Joined: Sun Jun 29, 2008 7:25 am

LED blink - Real time and Quartz Configuration

Post by carbon9 » Sun Jun 29, 2008 8:01 am

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
Attachments
LEDblink.mdl
(21.98 KiB) Downloaded 558 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: LED blink example question

Post by LubinKerhuel » Sun Jun 29, 2008 11:30 am

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
Attachments
LEDblink_v02.mdl
Model with few comments
(31.82 KiB) Downloaded 565 times

carbon9
Posts: 3
Joined: Sun Jun 29, 2008 7:25 am

Re: LED blink example question

Post by carbon9 » Tue Jul 01, 2008 6:39 am

Thank you very much for your comments.

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

Regards

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: LED blink example question

Post by LubinKerhuel » Tue Jul 01, 2008 7:22 am

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)

carbon9
Posts: 3
Joined: Sun Jun 29, 2008 7:25 am

Re: LED blink - Real time and Quartz Configuration

Post by carbon9 » Tue Jul 01, 2008 6:46 pm

Thanks for the replies. I'll try and if works, will post on this forum.

Regards

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 45 guests