Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Cfunction for more PWM?
Author | Message | ||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9082 |
Inspired by the Cfunction that adds multipule serial ports to a Micromite chip, I was wondering if the same thing can be done to generate other kinds of things. In my case, I am just about out of PWM channels on my test setup, so is it possible to write Cfunctions to generate extra PWM channels, SPI channels etc.... Now, I must state at this point, that I am really out of my league when it comes to Cfunctions - they are gobble-de-gook to me! So, what I am asking may well be totally impossible, so please be kind with your replies! But the Cfunction for the extra serial ports made me wonder if you can have Cfunctions to create extra ports like this for other stuff. You would then probably dedicate a chip just to dealing with that Cfunction ability - a PWM Cfunction would essentially turn a $3 Micromite into a multi-channel PWM controller for example. Yes? No? Impossible? Crazy? Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5923 |
PWM is run as a background task and I don't think you can do that with CFUNCTION's Jim VK7JH MMedit MMBasic Help |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3167 |
The PWM function in the Micromite is done using a feature of the PIC32 called output compare. There are five of these and when setup they run continuously generating the output waveform without intervention from the CPU. You could use a CFunction to also generate a PWM output but it would use the CPU to do that and it would not run in the background (as Jim pointed out). The SerialTx and Rx are similar. They do not run in the background, the BASIC program "pauses" while the character is being sent or received. However, because they do not need to run continuously (they return when the job is done) the wait is not so obvious to the BASIC programmer. Geoff Geoff Graham - http://geoffg.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9082 |
Cool, thanks for your reply, and also to Jim for his initial reply. It's no real problem. If I get desperate, it would be dead easy to just use another micromite chip as a slave PWM device, and issue PWM commands to it via the console pins. Each chip would give me another 5 PWM channels to play with. I2C or SPI is probably the way to do it, if more then one additional Micromite's worth of PWM was needed. Smoke makes things work. When the smoke gets out, it stops! |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
What is the function of those pwm pins? Sound, LEDs, power? There are a few chips available for that. With I2C. Microblocks. Build with logic. |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9082 |
PWM motor control. Each motor needs two PWM channels for full forward and reverse speed control. The Micromite can thus handle two seperate motors, but I need control for four motors, so I need at least 8 PWM channels. The PWM controller chips for the motors are BD6221 full-bridge controllers, and they need a PWM input from 20kHz - 100kHz. The Micromite's PWM can directly drive two of these 6221's for full control of two motors. Please do link me to any such I2C multi-channel PWM controller chip. That may well be a better solution. Smoke makes things work. When the smoke gets out, it stops! |
||||
hitsware Guru Joined: 23/11/2012 Location: United StatesPosts: 535 |
But only a single frequency needed, correct ? |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9082 |
Yes, single frequency. I have been using 30kHz. I seem to remember reading that the frequency has a bearing on the motor heat, but they are low-load, sporadic operation, so motor overheating should not be an issue really. Thanks for the link - checking that module out now... EDIT: This module is a 16 channel PWM LED controller. As it is single-ended, not an H-bridge output, I cannot use this to drive motors in forward/reverse. It's not really that much of a problem - a 2nd Micromite as a controller for the other two motors - job done, and only three bucks or so for the Micromite chip. EDIT: Oh, wait a minute - I see where you were going with the link in the above post. Use that module to generate the PWM signals, and feed them into the 6221 H-bridge controller chips. I think that is what you were suggesting. Smoke makes things work. When the smoke gets out, it stops! |
||||
hitsware Guru Joined: 23/11/2012 Location: United StatesPosts: 535 |
I was thinking a mosfet per output so 4 H-bridge/board .... (assuming it can be programmed that way (which seems plausible)) ? |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9082 |
Ahhh - even better! Nice idea. I will look into it. Smoke makes things work. When the smoke gets out, it stops! |
||||
Print this page |