I made the demo by specifying 100 as my top value this lets me set the fan speed from 0 to 100% in 1% increments.įinally, set the speed. Note that the PWM object expects two pins (you can use -1 as the parameter if only one pin is required, the PWM frequency, and the top end (100%) value. My code includes a setup() method this is the place where I put these calls. What Parallax calls objects are really class files, and you need to instantiate each object. I have a section in my code for this: con ' fan speed control outputs You need to define the pins that will connect to the FETs that drive your fans. Start a project and include it in the objects section: fans : "jm_dual_pwm_ez" ' * dual PWM control I don't have a lot of time, but it only took a few minutes to knock together a demo of the PWM object. You can point to your template and Propeller Tool will create a new file from it when you want. Save the template file to your templates folder, and all the other files to your Library folder so that they're available to every project. I've attached my default template as you may find it helpful. My friends and customer have certain expectations about my code and I'm able to meet that by starting every program with a template. I find that fast enough for the motors I've worked with. With 2 counter modules per cog, you can control two unidirectional motor outputs at up to 38kHz PWM frequency (with my "ez" driver). Given you're new to the Propeller, I suggest you focus on learning Spin (it's easy, you won't have trouble) and understanding the architecture of the Propeller).Īctually i was designing for a cog per fan motorĬogs are precious, especially with the P1 - get into the habit of not wasting them. If you find one or the other doesn't include a feature you'd like, send me a note and I'll consider it. These objects have been vetted commercially. Do not modify these objects, just link them to your program and call them as is. These objects should teach you a bit about the Propeller (which doesn't hide things like the Arduino does). This object does use a cog to create the fixed-frequency, variable duty-cycle PWM for motors. The file jm_dual_pwm_ez.spin will give you control over one or two motors using a common h-bridge chip (so you have forward and reverse control). This object does not consume any Propeller cogs (it runs in the main).įor motor control, you'll usually want higher PWM frequencies so the motors don't make noise. There is an 8-channel version of this chip (and the driver is identical) if you need more analog inputs. Since the device doesn't send data while receiving it, the DI and DO pins can be tied together with a resistor to save an IO on the Propeller - you get four inputs on three pins. The file jm_adc0834_ez.spin allows up to four analog inputs using a 3-wire SPI interface. I've attached two objects that have been used in commercial products from (so I know they work really well). There are no real analog (variable voltage) outputs on a standard Arduino, either the analogWrite() function is PWM.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |