Skip to content

Commit

Permalink
update comments in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Saeterncj committed Feb 11, 2019
1 parent 617f7b0 commit a43dabf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions MX1508.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ void MX1508::motorGo(long pwmSpeed) {
analogWrite16(_pinIN1, pwmSpeed);
} else if (this->_numPwmPins == PWM_2PIN) { // reverse fast decay
pwmSpeed *= -1;
//digitalWrite(_pinIN1, LOW);
analogWrite16(_pinIN1, 1);
analogWrite16(_pinIN2, pwmSpeed);
} else if (this->_numPwmPins == PWM_1PIN) { // reverse slow decay
Expand All @@ -87,7 +86,6 @@ void MX1508::motorGo(long pwmSpeed) {
} else if (this->_numPwmPins == PWM_2PIN) { // reverse slow decay
pwmSpeed *= -1;
pwmSpeed = map(pwmSpeed, 0, _pwmResolution, _pwmResolution, 0);
//digitalWrite(_pinIN2, HIGH);
analogWrite16(_pinIN2, _pwmResolution);
analogWrite16(_pinIN1, pwmSpeed);
} else if (this->_numPwmPins == PWM_1PIN) { // reverse fast decay
Expand Down
11 changes: 6 additions & 5 deletions examples/16bitResolutionPWM/16bitResolutionPWM.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

/*
* Created by: Cheng Saetern
* This example is meant to demonstrate the ability to adjust pwm frequency and/or
* resolution for pin 9 and 10 using function setPWM16(uint8_t prescaler, unsigned int resolution).
* Note that the equation for fast pwm frequency = frequency of MPU(16Mhz)/prescaler/resolution
* resolution for Arduino Nano/Uno pin 9 and 10 using function setPWM16(uint8_t prescaler, unsigned int resolution).
* Equation for fast pwm frequency = frequency of MPU(16Mhz)/prescaler/resolution
* F_PWM = 16000000/prescaler/resolution.
* prescaler argument can only be values of 1-5, representing 1,8,64,256,1024 respectively.
* resolution must be a value from 0-65535.
* prescaler argument value MUST be between 1-5, representing 1,8,64,256,1024 respectively.
* resolution MUST be a value from 0-65535.
*/

#include <MX1508.h>
Expand All @@ -29,7 +30,7 @@ void setup() {

motorA.setPWM16(2,resolution); // prescaler at 8, resolution 1000, PWM frequency = 16Mhz/8/1000=2000Hz
// prescalar 1=1, 2=8, 3=64, 4=256, 5 =1028
/*------------ The Class function is defined as below-----------------
/*------------ setPWM16 Class function is defined as below-----------------
void MX1508::setPWM16(uint8_t prescaler, unsigned int resolution){
if(prescaler > 5 || prescaler == 0) prescaler = 3; // default to 64 if not in range.
DDRB |= _BV(PB1) | _BV(PB2); // set pin 9and 10 as outputs
Expand Down
3 changes: 1 addition & 2 deletions examples/exampleMX1508/exampleMX1508.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
* NumOfPwmPins, either use 1 or 2 pwm.
* I recommend using 2 pwm pins per motor so spinning motor forward and backward gives similar response.
* if using 1 pwm pin, make sure its pinIN1, then set pinIN2 to any digital pin. I dont recommend this setting because
* we need to use FAST_DECAY in one direction and SLOW_DECAY for the other direction.
* watch video for better description.
* we need to use FAST_DECAY in one direction and SLOW_DECAY for the other direction.
*/
MX1508 motorA(PINA,PINB, FAST_DECAY, NUMPWM);

Expand Down

0 comments on commit a43dabf

Please sign in to comment.