CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PWM1 AND PWM2 with 18f46k22[SOLVED]
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Mon Sep 21, 2020 2:45 am     Reply with quote

https://ibb.co/Y381cX3
So what do you say about the H bridge you see in schematic?
I think one of the transistors drew too much current and burned my C2 pin.
Commonly, I know Pmos is used on the top and Nmos on the bottom. Is it unreasonable to use 4 mosfetide n channels?
Do you have a link that you use commonly and to recommend?

Good work.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Sep 21, 2020 3:07 am     Reply with quote

Actually, 4 N-Mos is a very common configuration. N-Mos FET's are actually
slightly more efficient than P-Mos types.
However there is a huge problem with what you post. Voltage.

A Nmos FET requires It's gate to be Vgs volts above it's source to turn
on. This means that depending on the Vgs of the FET's involved, the
source can only pull up to 12v - Vgs. Result the top FET's would run very
hot indeed....
Proper drivers for an Nmos FET used like this will have a capacitive charge
pump inverter to generate a supply rail Vgs above the 12v, and the upper
control transistors will switch up to this, instead of using the 12v supply.
Also, the gate of a power FET has enormous capacitance (power FET's are
actually made by combining hundreds or even thousands of smaller FET's
in the single package) - result massive gate capacitance.
Now this capacitance means that to switch the gate quickly very large
currents have to be delivered by the driver. If this is not done, the FET
will take a very long time to switch, and the result is yet more heat.
Proper FET gate drives will typically be able to deliver well over an amp.
Now the drive ability affects the time to turn off as well as the time
to turn on. My guess would be that the transistors were remaining at
least partially turned on, when the next was also turning on. Ugh....
These problems are exacerbated by the high switching speeds you were
using 10KHz, is a fast rate to switch a power FET and needs careful
design.

Look at proper high side drive circuits.
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Mon Sep 21, 2020 3:43 am     Reply with quote

Dear Ttelmah. Thank you for answer.
How old are you?
And how do you manage to be so good in both power electronics, digital electronics, and software. Likewise temtronic.
Almost every subject has an application in the past.
In my opinion, in this form; The following types of headings should be fixed:
- While starting to program
- Being a step-by-step electronics master
- Make sure / never do
- ...
- ...
In fact, if newbies start using your experience, it will progress much faster.
Previously you asked "Why don't you open a Youtube channel?"
I asked. I guess you don't have time.
But it would be great if fixed headers were opened like this in this form.

A humble suggestion ...
Best regards Very Happy
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Sep 21, 2020 4:52 am     Reply with quote

As Mr. T points out there is a LOT of design details that need to be done before an H-bridge will function ! You should consider buying an 'off-the-shelf' chip that will control your motor. Depending on your motor's specs (usually current draw (amps), is the important one), you may be able to buy the 'chip' for $1 or $2. it would simple go in between PIC and motor. Known to work, simplifies wiring, robust and could be cheaper than designing/building a discrete H-driver.
In the good old days, yes, we'd spend a lot of time calculating, ordering, bench testing, waiting for 'magic smoke to clear'...... Today, you can go onto the Internet, order a 'module' and finish the project quickly.....
I've done that with USB and PICs. Instead of using a PIC with internal USB, it's cheaper, faster, easier to buy a USB<>TTL module. Same with RTC, I buy 'modules'. I'm sure there has to be several H-bridge modules that'd interface with your PIC<>motor project.

Jay
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Mon Sep 21, 2020 12:29 pm     Reply with quote

Actually, when I used a module in the project, I cannot say that I did this project.
because I learn less when using modules.
But the project doesn't end when I try to do everything myself? Very Happy
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Sep 21, 2020 2:01 pm     Reply with quote

Gee, if you can't use a module for the 'PIC > Motor' interface, you 'should' not use a PIC and try using discrete 4000 series CMOS ! Smile
Modules aren't really a 'cheat', just a nice way to eliminate a LOT of possible wiring errors, bad PCB layout, etc. They also allow you to concentrate your time on code cutting, instead of tracking down faulty hardware problems like solder whiskers or , oopsy D+ and D- are reversed...... Sad

I understand the education of using discrete parts but designing a high current H-bridge is NOT for 1st year students !!!

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Sep 22, 2020 1:11 am     Reply with quote

The other problem is that things like power circuits, and H bridges, don't
teach you anything in prototypes. As soon as you move from some form of
prototype form, to a genuine board, 'everything changes', and you have
to design it again. Current flows in the grounds, and pick-up between
parts, in particular are a 'fact of life' in such circuits, and have to be
dealt with. IC manufacturers for things like high side power drivers will
include in their data, 'recommended layouts', and once you use these,
you might as well use a pre-built board. If you don't use these, be prepared
for just how many parts _will_ give problems.
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Tue Sep 22, 2020 4:28 am     Reply with quote

I understand.
This job is much harder than I thought.
I researched the modules.
I found a really effective and cheap one. I think I will use this.
https://cdn.shopify.com/s/files/1/0672/9409/files/VNH2SP30_datasheet.pdf?9471026293914021412

However, I haven't stopped designing an H-bridge. Can you recommend me a quality simulation program? I start learning with simulation.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Sep 22, 2020 5:21 am     Reply with quote

The link downloads a PDF of an 'H-bridge driver' chip NOT a 'module'.
A 'module' should be a small PCB with some (6-8) pins to connect signals from the PIC, 2 large screw terminal for PSU, and 2 large screw terminals to connect the motor. It will have an h-bridge driver chip, 4 MOSFETS, a heatsink, as well as other 'support' components.
You could easily spend 1-2 manyears designing a proper H-bridge ! That's why I suggest using an 'off-the-shelf' premade module.

Just Google ' h-bridge module'. You'll get lots of hits with images of them.

Cost usually depends upon power (amps) and features. Without knowing your motor, I think under $20 would get you a module. Always buy 2 though......

Jay
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Tue Sep 22, 2020 6:19 am     Reply with quote

Yes my mistake
https://cdn.shopify.com/s/files/1/0672/9409/files/VNH2SP30_dc_motor_driver.pdf
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Thu Oct 08, 2020 6:57 am     Reply with quote

Ttelmah wrote:
Two separate things here.
The first is down to the mode you run the PWM.

In standard mode (CCP_PWM), it only generates the single signal on PWMx.
In it's enhanced mode, you have four PWM outputs from each PWM, and these
go to P1A, P1B, P1C & P1D. The signals from these can be 'steered' to
different pins, or used as half bridge or full bridge pairs. The pulse steering
is done using the settings CCP_PULSE_STEERING_x in the CCP setup. Where
'x' is the output you want to use (A, B, C or D).
However the second part here is an error in the data sheet. C0, is P2B,
which is the 'B' output from PWM2, not from PWM1. The title is right in
the pin names, but wrong in the description. So you can't use this for PWM1...
Sad


In addition, CCS C seems to have ccp2 feature on c0 pin in 18f46k22.h
//////// Fuses: NOHFOFST,HFOFST,TIMER3B5,TIMER3C0,CCP2C0,CCP2D2,NOMCLR,MCLR
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group