Dual Motor Shield - Make the link between the PWM value and the actual voltage

NBCS · 2 · 12698

NBCS

  • Newbie
  • *
    • Posts: 1
    • View Profile
Hello,

I recently bought a Tinyzero and the dual motor shield. I'm trying to control a micro perilstaltic pump that has a little motor working between 0-3.3V (can go up to 5 but only for short periods). The company that sells the pump actually uses a tinyzero and a dual motor shield for their controller. So I decided to make it myself.
I just need the pump to work like every 5 minutes for 1 minutes at a given very low voltage (they provide a flow speed according to voltage).
As the pump does not need more than 3V, I did not put any external power than the usb cable linked to my PC on the tinyzero.

I think I'm not fully understanding the concept of PWM but I would not want to fry my pump, it's pretty expensive.
I'm a little bit confused by this PWM value and what it actually represent. Is there any way to know which voltage for which PWM I'm actually applying?

I tried and modified the example code but, same, got confused playing with the PWM, the steps, stepsize and the delay in the void loop. The pump was behaving really weirdly.

The best I had was (but still pumping too fast or too slow) was:

int maxPWM=100; //tried 330 too but barely pumping
int steps=10;
int stepSize=maxPWM/steps;

void setup(){
  SerialMonitorInterface.begin(9600);
  Wire.begin();
  while(!SerialMonitorInterface)//This will block until the Serial Monitor is opened on TinyScreen+/TinyZero platform!


  //The value passed to begin() is the maximum PWM value, which is 16 bit(up to 65535)
  //This value also determines the output frequency- by default, 8MHz divided by the maxPWM value
  if(motor.begin(maxPWM)){
    SerialMonitorInterface.println("Motor driver not detected!");
    while(1);
  }
  //The failsafe turns off motors if a command is not sent in a certain amount of time.
  //Failsafe is set in milliseconds- comment or set to 0 to disable
  motor.setFailsafe(1000);
}

void loop(){
  int i;
  for(i=-maxPWM;i<maxPWM;i+=stepSize){
    delay(10);
    motor.setMotor(1,i);
  }
}

I also tried simply:

motor.setMotor(1,330);

but it did not seemed to trigger the motor at all.

Thank you


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 437
    • View Profile
Hi there,

There are lots of resources to learn more about PWM. You can start here: https://www.arduino.cc/en/Tutorial/Foundations/PWM

As for the voltage output, you can measure this directly using a voltmeter.

I hope that helps!

Cheers,
RĂ©na


 

SMF spam blocked by CleanTalk