Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 30, 2024, 06:31:45 06:31


Login with username, password and session length


Pages: [1]
Print
Author Topic: Converting input PWM of 1V-3.5V to 0V-5V output  (Read 5139 times)
0 Members and 1 Guest are viewing this topic.
leaveme
Junior Member
**
Offline Offline

Posts: 93

Thank You
-Given: 38
-Receive: 15


« on: August 09, 2013, 11:39:47 11:39 »

I have a situation where I need to convert the input PWM of 1V-3.5V to an output of 0V-5V and I use the schmitt trigger (74HC14) to do that. The output PWM then connected to PIC18F2520 for further processing. But I need to reduce the number of parts due to space constraints.

I would like to ask, can I do it by the PIC itself (without using a 74HC14) or any other thought?
« Last Edit: August 09, 2013, 11:42:03 11:42 by leaveme » Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4667

Thank You
-Given: 834
-Receive: 4323


There is no evidence that I muted SoNsIvRi


« Reply #1 on: August 09, 2013, 01:06:43 13:06 »

have you tried direct input, logic level for low is 0 - 0.8 and a high 2.7 - 5volt average

opps I see your low is 1 volt.

can you add fet ?
« Last Edit: August 09, 2013, 01:09:47 13:09 by pickit2 » Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
pertican
Active Member
***
Offline Offline

Posts: 172

Thank You
-Given: 436
-Receive: 1130



« Reply #2 on: August 09, 2013, 01:11:26 13:11 »

You can use the transistors or FET
http://electronics.stackexchange.com/questions/30737/transistors-and-pwm


Instead 12v fan, put a 10k resistor so collector is pwm output.

Regards
« Last Edit: August 09, 2013, 01:34:03 13:34 by pertican » Logged

leaveme
Junior Member
**
Offline Offline

Posts: 93

Thank You
-Given: 38
-Receive: 15


« Reply #3 on: August 09, 2013, 01:42:31 13:42 »

Just few more info about my project.
The PWM is generated from the controller and converted using 74HC14. PIC then takes the PWM and drives two different devices. Unit-1 requires the the direct PWM but Unit-2 requires analog voltage. Here is the flow chart:

Code:
                                                    |---- PWM1 ---> Control Unit-1 
PWM (1V-3.5V) ---> 74HC14 (0V-5V) ---> PIC18F2520 --|
                                                    |---- PWM2 --- RC filter ---> Control Unit-2 (Analog 0V-5V)

@pickit2:
Fet can be added. But how about the switching time?
Logged
Gallymimu
Hero Member
*****
Offline Offline

Posts: 704

Thank You
-Given: 152
-Receive: 214


« Reply #4 on: August 09, 2013, 04:52:23 16:52 »

switch time on a fet could be fine depending on how it's driven.  At 50Hz I doubt you'd have a problem unless you need less than 1us latency (which I doubt since you are feeding it through a processor.  You'll want a logic level low input capacitance FET.
Logged
Checksum8
Active Member
***
Offline Offline

Posts: 132

Thank You
-Given: 124
-Receive: 102


« Reply #5 on: August 09, 2013, 04:54:29 16:54 »

That pic has two analog comparators. If these pins are available in your project it could be one solution. See data sheet
Logged
leaveme
Junior Member
**
Offline Offline

Posts: 93

Thank You
-Given: 38
-Receive: 15


« Reply #6 on: August 09, 2013, 05:46:10 17:46 »

That pic has two analog comparators. If these pins are available in your project it could be one solution. See data sheet
Few more words please...
Logged
zab
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 25
-Receive: 58


« Reply #7 on: August 09, 2013, 07:05:29 19:05 »

Comparator are used to compare the signal with a reference signal and out put is determined by this reference accordingly you can get high or low signal. If your input signal is higher than ref out put would be high If it is low then output would be zero. It is very simple. Just use these comparators to do the required job without converting the voltage level.
Logged
Checksum8
Active Member
***
Offline Offline

Posts: 132

Thank You
-Given: 124
-Receive: 102


« Reply #8 on: August 09, 2013, 07:09:35 19:09 »

The PIc18F2520 has a "Comparator Module" which contains two analog comparators. The I/O pins are on portA. In your example you would feed the pulse train into the positive input of one of the comparators. On the negative input, a resistor voltage divider set to half of your 1v to 3.5v signal or about 2.25v. Every time the input crosses 2.25v the output of the comparator changes states. Now you have a 5 volt output.

I have used these to 10khz so I doubt you will have any problems at 50hz. This module can also generate internal interupts on change. There is also an internal voltage reference, which may eliminate the need for external voltage divider.

Read this to start
http://ww1.microchip.com/downloads/en/DeviceDoc/41215c.pdf
« Last Edit: August 09, 2013, 07:20:47 19:20 by Checksum8 » Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 582

Thank You
-Given: 496
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #9 on: August 10, 2013, 12:10:17 00:10 »

+1 use the analog feature (comparator) on the PIC.
Logged

If I have said something that offends you, please let me know, so I can say it again later.
leaveme
Junior Member
**
Offline Offline

Posts: 93

Thank You
-Given: 38
-Receive: 15


« Reply #10 on: August 10, 2013, 05:33:20 05:33 »

Thanks guys.
So, you are suggesting me to use the internal comparator.
Is it something like this:

Code:
// CCS C

#define TEST_LED  PIN_A4

// Trigger comparator INT on change
#int_COMP              
void  COMP_isr(void)
{    
   if(C1OUT == 1)  
      output_high(TEST_LED);  
   else
      output_low(TEST_LED);
}

void main()
{
   output_low(TEST_LED);  // Turn off the LED initially

   // Comparator input voltage is on pin A0, with internal
   // Vref, and inverted Comparator output.  
   // The inversion is done so that when the input voltage
   // is greater than Vref, the comparator output will go high.
   setup_comparator(A0_VR_A1_VR | CP1_INVERT);  // CM2:CM0 = 110, CMCON=0000 0110
   setup_vref(VREF_LOW | 15);                   // Vref = 5v * (15/32) = 2.35v
  
   // Wait for the Comparator mode change
   delay_us(20);                

   clear_interrupt(INT_COMP);  

   enable_interrupts(INT_COMP);     // Enable INT COMP
   enable_interrupts(GLOBAL);       // Enable Global INT

   while(1);
}
« Last Edit: August 10, 2013, 05:46:13 05:46 by leaveme » Logged
Catcatcat
Senior Member
****
Offline Offline

Posts: 432

Thank You
-Given: 284
-Receive: 1654



WWW
« Reply #11 on: August 10, 2013, 08:08:51 08:08 »

The logic levels, the same, you can simply connect directly
Logged
Vineyards
Active Member
***
Offline Offline

Posts: 168

Thank You
-Given: 64
-Receive: 37


« Reply #12 on: August 10, 2013, 08:58:39 08:58 »

Above suggestions will work unless there are no ground contention related problems (ground loops). I wouldn't connect an external signal to any of the pins of a microprocessor without employing some sort of isolation. Isolation necessitates additional components (DC-DC converters, digital/analog isolators or optocouplers).

If you avoid them your circuit may work on the bench but will probably fail in an industrial environment.
Logged
Signal
Active Member
***
Offline Offline

Posts: 200

Thank You
-Given: 113
-Receive: 81



« Reply #13 on: June 30, 2014, 03:28:16 15:28 »

can I do it by the PIC itself (without using a 74HC14) or any other thought?
If noise immunity and isolation problems are not considering here then simple resistive divider is completely enough. No need of comparators or other level shifters. PIC18F2520 has TTL inputs too. From http://ww1.microchip.com/downloads/en/DeviceDoc/39631E.pdf:
VIL = 0.8 V (D030A)
VIH = 2 V (D040A)
For 5/8 divider we have: 1 V -> 0.625 V, 3.5 V -> 2.18 V.
Added Ohms and small overshot are not a problem if levels are stable enough and while 50 Hz gives a time even for light filtering.
Logged

Give a right name to a right game and play it right
Gallymimu
Hero Member
*****
Offline Offline

Posts: 704

Thank You
-Given: 152
-Receive: 214


« Reply #14 on: July 01, 2014, 03:24:38 03:24 »

heh, you are a year late to this part!
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC