Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 06, 2016, 08:50:45 20:50


Login with username, password and session length


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

Posts: 81

Thank You
-Given: 30
-Receive: 15


« on: August 09, 2013, 12:39:47 12: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, 12:42:03 12:42 by leaveme » Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #1 on: August 09, 2013, 02:06:43 14: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, 02:09:47 14:09 by pickit2 » Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
pertican
Active Member
***
Offline Offline

Posts: 171

Thank You
-Given: 436
-Receive: 1135



« Reply #2 on: August 09, 2013, 02:11:26 14: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, 02:34:03 14:34 by pertican » Logged

leaveme
Junior Member
**
Offline Offline

Posts: 81

Thank You
-Given: 30
-Receive: 15


« Reply #3 on: August 09, 2013, 02:42:31 14: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: 579

Thank You
-Given: 101
-Receive: 151


« Reply #4 on: August 09, 2013, 05:52:23 17: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
V.I.P
Junior Member
*****
Offline Offline

Posts: 71

Thank You
-Given: 44
-Receive: 53


« Reply #5 on: August 09, 2013, 05:54:29 17: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: 81

Thank You
-Given: 30
-Receive: 15


« Reply #6 on: August 09, 2013, 06:46:10 18: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: 132

Thank You
-Given: 24
-Receive: 54


« Reply #7 on: August 09, 2013, 08:05:29 20: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
V.I.P
Junior Member
*****
Offline Offline

Posts: 71

Thank You
-Given: 44
-Receive: 53


« Reply #8 on: August 09, 2013, 08:09:35 20: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, 08:20:47 20:20 by Checksum8 » Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 544

Thank You
-Given: 357
-Receive: 126


Very Wise (and grouchy) Old Man


« Reply #9 on: August 10, 2013, 01:10:17 01: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: 81

Thank You
-Given: 30
-Receive: 15


« Reply #10 on: August 10, 2013, 06:33:20 06: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, 06:46:13 06:46 by leaveme » Logged
Catcatcat
Active Member
***
 Warned
Offline Offline

Posts: 117

Thank You
-Given: 89
-Receive: 258



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

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

Posts: 130

Thank You
-Given: 36
-Receive: 25


« Reply #12 on: August 10, 2013, 09:58:39 09: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: 102

Thank You
-Given: 47
-Receive: 33


« Reply #13 on: June 30, 2014, 04:28:16 16: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: 579

Thank You
-Given: 101
-Receive: 151


« Reply #14 on: July 01, 2014, 04:24:38 04: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