Controlling Relay with Micro controller.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Controlling Relay with Micro controller.

1,317 Views
victorrod
Contributor I

I am using Kinetis KLO M0 family as requirement and I have to

run a relay that is supplying 277VAC @ 5A to the load.

Also I need to be turning it ON and OFF every 9 seconds. I am

wondering which outputs should I be using.

I can design the power conversion needed, but I am not much

familiar with Microcontroller.

Thanks

Labels (2)
0 Kudos
6 Replies

890 Views
victorrod
Contributor I

One of the requirements is to use Freescale Kinetis KLO cortez ARM microcontrollers.

@Jim to reply you,

Yes I will be driving Relay by driving the transistor or the FET using the MCU.

0 Kudos

890 Views
LuisCasado
NXP Employee
NXP Employee

Hi,

You can use any GPIO of KL0x MCU. But you will need a external driver, a small transistor is enough, a darlington transistor is much better, like MPSA14. It depens on the voltage and current you need in the relay coil, tipically 12V and some mA. You will need a parallel diode with the relay coil.

http://www.onsemi.com/pub_link/Collateral/MPSA13-D.PDF

Something like this:

2013-05-16_224143.png

If you need to drive multiple relays, you can use an ULN2803, for example.

Luis

890 Views
victorrod
Contributor I

So GPIO of KLOx MCU is connected to TTL input of the transistor??

Also which clock should I use to drive the circuit ON and OFF every 9 second?  and how will it control my GPIO output?

(MCGOUTCLK, MCGFLLCLK, MCGPLLCLK, OR something else??)

Thanks

Victor

0 Kudos

890 Views
LuisCasado
NXP Employee
NXP Employee

Hi,

Yes, GPIO to resistor.

You can use any timer (TPM, LPTMR) to generate a basetime to count seconds and drive the pin when you need.

Best Regards,

Luis

890 Views
victorrod
Contributor I

Hello,

Since I am a beginner I am looking for options to do the timing easily.

I also have a requirement of linking the relay to ON/ OFF button

1. time delay function in while loop,

But I dont know what other variables and module would I have to initialize? Would it calculate internally and just put the trigger after every assigned delay time?

while (1) {

    
       _io_ioctl(file1, GPIO_IOCTL_WRITE_LOG1, NULL);
      
       _time_delay(9000);
      
       _io_ioctl(file1, GPIO_IOCTL_WRITE_LOG0 NULL);
      
       _time_delay(1000);
}  

2.  Use PWM to control the transistor.

I will have to learn how to set TPM for PWM.

https://community.freescale.com/message/319470#319470

https://community.freescale.com/message/63827#63827

Looks like I will also have to learn how to divide clocks, so use EXTAL (which is 8MHz) then learn how to code/ set TPM overflow

and then learn how to link it to GPIO output.

3.

Designer can use a PIT timer to generate a periodic 9 seconds interrupt.

And in the PIT interrupt service routine, customer can set relay control pin output status.

Do you have any examples that I could read that will help me understand how GPIO timings can be adjusted

Thanks

0 Kudos

890 Views
JimDon
Senior Contributor III

I don't think you want to use PWM in this way, if you mean to use it to turn the relay on and off.

I also don't think you need to use two threads on the forum, but that is your choice.

If you have given us the full requirements of your application, it might be simpler to not use MQX and use PE to setup an IO bit and a timer. You will certain learn more about MCUs.

0 Kudos