Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Simple PWM LED dimming with delay

Status
Not open for further replies.

Pha5e

Advanced Member level 4
Joined
Dec 9, 2011
Messages
101
Helped
7
Reputation
14
Reaction score
6
Trophy points
1,298
Location
I am not here - it's an illusion
Activity points
1,928
Hi,

I'm fairly new to microcontroller design and have been asked to implement an LED delay for a display piece. It needs to sense when someone walks close and fade LEDs to maximum brightness and stay on for a period of time. I am thinking of using some form of motion sensor to trigger a microcontroller input pin.

I'm considering either using an ST Micro Nucleo board or a PIC Microchip part. Which is likely to be easier to implement the above? Any help is appreciated!

Thanks.
 

Depends on which device you're more comfortable/familiar with. Either could do the relatively task.
 

Depends on which device you're more comfortable/familiar with. Either could do the relatively task.

I would be approaching this as a beginner so am not really more familiar with either. Which is going to be the easiest to implement with little coding experience? I know ST Micro has the CubeMX tool to help configure peripherals.
 

I'm not familiar with the ST family, but Microchip provides a LOT of free tools, examples, tutorials etc.
 

Hello!

ST has also free tools. There is a free development environment (no limitation whatosever).
There is quite some code as well. And the ARM architecture is really ubiquitous, the boards
are extremely cheap and powerful (I just bought a nucleo with a F7 processor. A lot of Flash,
a lot of RAM, running at 216 MHz and for 25 USD.

Using CubeMX is the right way to do 90% of the job. In your case, the project is so simple that
it would rather be 99.9%.
A nucleo board is anyway 10000 times too powerful for what you are trying to do, but as I suppose
you will start from there and then develop more enhanced programs, this is likely to be a good choice.
You can choose basically any of the boards, they are all in the same price range.

Now for your problem, I suppose you have already a detector, right? I'm not sure what kind of output
you get, but if it's like, say, Panasonic's Napion, you simply get a on / off output when somebody
approaches. In this case, you have to detect on an input port and drive the backlight with a PWM.
Don't use a delay as stated in the title!!!

What you have to do:
- Start CubeMX, configure it for the board you have on your desk (new project, then choose).
- Choose one free GPIO (they are in gray on the CPU map).
- Click it and choose GPIO_EXTx, x being the number of the pin. I'm doing it at the same time,
for example in my case, I have clicked PH3, and the menu shows GPIO_EXTI3.
- Choose another GPIO for PWM

Generate the code.

- Once generated, open your IDE, go to the code and add an interrupt function in order to receive the
detector interrupt.
- Write your PWM function (example SetBacklight(uint8 val)).

The next step would be to fade in and fade out slowly, using SysTick.

Etc...

Dora
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top