Notifications
Clear all

Couple Newbie Questions

6 Posts
4 Users
0 Reactions
952 Views
(@cvanderby)
Member
Joined: 4 years ago
Posts: 2
Topic starter  

HI all glad to here Chad from Saskatchewan.  I

have been working on a project using an Arduino uno, bornes rotary encoder, display 4X20 with IC2 and Clearpath servo motor.  I can get the encoder to control the motor through the arduino and see selected speed on the display properly.  The trouble two problems i have are when I dial up encoder once it gets over 10 or 100 when i go down it leaves and extra 0 so 100..990..980..970 and so on down to 000.  Any way to get rid of the extra 0?   Second is I would like to read true speed of the motor which is possible with an HLFB wire of the motor that will feed back true motor speed but it sends the signal back as 45 or 482 HZ waveform whos duty cycles varies proportionally to actual motor speed.

5% duty cycle = 0% max speed, 100% duty cycle = 100% max speed Max speed is set to 256 rpm in this case, 0% duty cycle is considered OFF or shutdown

I have pin 11 as a INPUT_PULLUP as it requires a resistor. I can make it read a number but its not correct. Using this for motor code. 

any suggestions would be greatly appreciated.

Chad V.


   
Quote
JoeLyddon
(@joelyddon)
Member
Joined: 5 years ago
Posts: 157
 
Posted by: @cvanderby

HI all glad to here Chad from Saskatchewan.  I

have been working on a project using an Arduino uno, bornes rotary encoder, display 4X20 with IC2 and Clearpath servo motor.  I can get the encoder to control the motor through the arduino and see selected speed on the display properly.  The trouble two problems i have are when I dial up encoder once it gets over 10 or 100 when i go down it leaves and extra 0 so 100..990..980..970 and so on down to 000.  Any way to get rid of the extra 0?   Second is I would like to read true speed of the motor which is possible with an HLFB wire of the motor that will feed back true motor speed but it sends the signal back as 45 or 482 HZ waveform whos duty cycles varies proportionally to actual motor speed.

5% duty cycle = 0% max speed, 100% duty cycle = 100% max speed Max speed is set to 256 rpm in this case, 0% duty cycle is considered OFF or shutdown

I have pin 11 as a INPUT_PULLUP as it requires a resistor. I can make it read a number but its not correct. Using this for motor code. 

any suggestions would be greatly appreciated.

Chad V.

Welcome aboard, Chad!

I wish I could help with your problem...  but, I'm new to it all too...  Someone will help you, I'm sure.

Good luck!

As part of the debugging process, if you can insert

"Print "At this point, x=";

Println x;"

Peeking at the contents of various things at various times can sometimes give you BIG clues as to what is wrong, etc.

Have Fun,
Joe Lyddon

www.woodworkstuff.net


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@cvanderby

So is this the Clearpath servo motor?

Perhaps if you post the code you are using the programmers here might be able to help?
The more details you provide (your current wiring) the more likely someone might know how to fix any issues.

https://forum.dronebotworkshop.com/question-suggestion/sticky-post-for-editing/#post-4939

 


   
ReplyQuote
(@cvanderby)
Member
Joined: 4 years ago
Posts: 2
Topic starter  

Yes this is the motor I have just used to map function and got it close enough to what I need.  But I would still like to get my display numbers to work better  the motor read out does similar  say its running at 158 when I go motor off it will show 008 or 050 I would like it to go to 0.  Here is a copy of the code.

#include <Wire.h>
#include <FastIO.h>
#include <I2CIO.h>
#include <LiquidCrystal_I2C.h>
#include <ACE128.h> // https://github.com/arielnh56/ACE128

#include <ACE128map12345678.h> // mapping for pin order 12345678

 

// Include Wire Library for I2C

// Include NewLiquidCrystal Library for I2C

// Define LCD pinout
const int en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

// Define I2C Address - change if reqiuired
const int i2c_addr = 0x27;

LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

// Pin x of UNO connected to pin x of Encoder (example: UNO pin 2 connected to pin 1 of encoder, etc...)
ACE128 myACE(2,3,4,5,6,7,8,9, (uint8_t*)encoderMap_12345678);

int16_t multiturn_encoder_value; // Variable to hold multiturn value of encoder (-32768 to 32767)
int pwmToMotor = 10; //Set PWM pin for motor
int HLFB = 11;
const int motorDR =12;
int rollsp;
double channel;
void setup()
{
myACE.begin();
// Set display type as 16 char, 2 rows
lcd.begin(20,4);

// Print on first row
lcd.setCursor(0,0);
lcd.print("Fly'n Dutchman AG");

// Wait 1 second
delay(1000);

// Print on second row
lcd.setCursor(0,1);
lcd.print("Spreader V1.0");
pinMode(pwmToMotor, OUTPUT); //Set PWM Pin as an Output
//Set Motor Enable Pin as an Output

pinMode(HLFB, INPUT_PULLUP);
// Wait 8 seconds
delay(8000);

// Clear the display
lcd.clear();

}

void loop()
{
multiturn_encoder_value = myACE.mpos();
if (multiturn_encoder_value != multiturn_encoder_value) { //If it's different then it was 'last' time the loop was run, change the 'last' variable to the new value
multiturn_encoder_value = multiturn_encoder_value;
}
if (multiturn_encoder_value < 0) { //Keep the motor RPM from going below zero
multiturn_encoder_value = 0;
}

if (multiturn_encoder_value > 256) { //Keep the motor RPM from going above 3000
multiturn_encoder_value = 256;
}

analogWrite(pwmToMotor,multiturn_encoder_value);

lcd.setCursor(0,0);
lcd.print("SET RPM ");
lcd.print(multiturn_encoder_value );
lcd.setCursor(0,2);
lcd.print("ROLLER RPM: ");
{
channel=pulseIn(HLFB,LOW);
rollsp = map(channel,1230,20900,0,254);
if (rollsp < 0) {                           //Keep rollsp for showing below 0
rollsp = 0;
}
lcd.print(rollsp );

lcd.setCursor(0,3);
if(channel == 0){
lcd.print("Roller OFF/Armed");}
else{lcd.print("RUNNING ");}
delay(1000);
}
}

Any tips appreciated


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 
Posted by: @Cvanderby

lcd.clear();

It looks like the only thing you need to do to fix your 000  problem is to move the lcd.clear(); from the last statement in the setup section to the first statement in the loop section.


   
ReplyQuote