Notifications
Clear all

Stepper and load cell

150 Posts
8 Users
31 Likes
3,498 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6982
 

@the-apprentice @inst-tech You can't just tell us the error, take a screen shot of the error including a few lines before and after it. Usually the first line in RED is the key, scroll back to the beginning of the compiler output then scroll forward until you see the first RED lines. 

Also, post a link of the source code or the actual code.

If what you are compiling is the sample from @inst-tech, I got it to compile clean after changing the pins to 2 and 3 since for my board A0 and A1 were unknown.

My first guess is you have not installed the HX711 library. Do that and try again.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inst-Tech reacted
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 

Posted by: @the-apprentice

@inst-tech I keep getting this error.

Compilation error: no matching function for call to 'HX711::HX711()'

@the-apprentice, Try modifying the code that defines the Object called scale " HX711 scale;" to HX711 scale(byte dout_pin, byte sck_pin);

In my simulation, it wouldn't allow me to use that constructor, so I just used what in in the code you now are using. This tells the compiler that the HX711 is using pins A1 & A0 for communication between the HX711 and the Arduino. And Please follow @zanders suggestion to look at the compilers errors and post them so we can see what else might be missing.

I've ordered the parts for the hardware to build a protype of this to see how accurate my simulation software is, but as @zander has already been able to compile it clean, I think there may be something else..At anyrate, this is part of the learning process... it's called troubleshooting...lol You'll most likely be doing a lot of that as you progress.. If it was easy, everyone would be doing it!

Hang in there, you'll eventually get it to work and the buttons on your shirt will pop out... 😆 

regards,

LouisR

 

LouisR


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6982
 

@inst-tech @the-apprentice I had to replace A0 and A1 as they were undefined. I used the actual pin numbers. I know that is bad form, but I was just quickly trying to verify if the code was clean. It is.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inst-Tech reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6982
 

@inst-tech @the-apprentice A quick follow-up to my prev post. Changing the A0, A1 to 2 and 3 was just a temp fix to see if the code is clean. The correct fix is changing the board to a UNO. I also commented out the library and did NOT get the error @the-apprentice got. I have seen that error but do not recall where.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inst-Tech reacted
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 

@zander , Ron... I would get that error in my simulation when I tried to set up the constructor with the form HX711 scale(byte dout_pin, byte sck_pin); where the byte dout_pin and byte sck_pin where defined by Const byte dout_pin=A1; and const byte sck_pin = A0.. so that's why it's just HX711 scale; in the sketch I posted. I will know more about how that will work when I get the actual HX711 and try the code on a protype..Thanks for your help and guidance..

regards,

LouisR

LouisR


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6982
 

 

@inst-tech FYI @the_apprentice Ok, now I get it. The constructor is empty, see pic. This library uses the begin style so the correct syntax is simply

HX711 scale; in the globals
and in setup use
scale.begin(dout_pin, sck_pin);
 
Screenshot 2024 02 17 at 12.39.24

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
The apprentice
(@the-apprentice)
Member
Joined: 4 months ago
Posts: 61
Topic starter  

I have tried and can not get it to work. It wont compile. I have added the Millis to it but still no go. 

#include<FlexyStepper.h>


#include"HX711.h"


int reverseSwitch = 1;  // Push button for reverse
int driverPUL = 5;    // PUL- pin
int driverDIR = 6;    // DIR- pin
int spd = A0;     // Potentiometer
int pd = 0;       // Pulse Delay period
boolean setdir = HIGH; // Set Direction
HX711 scale(2, 3);    // parameter "gain" is ommited; the default value 128 is used by the library
unsignedlong currentMillis = 0;
unsignedlong stepperPreviousMillis = 0;
constunsignedlong stepperPeriod = 5;
voidrevmotor(){
setdir = !setdir;}


voidstepper(){
if(currentMillis - stepperPreviousMillis >= stepperPeriod)
  stepperPreviousMillis - currentMillis;
}


voidsetup(){
Serial.begin(9600);
Serial.println("HX711 Demo");


Serial.println("Before setting up the scale:");
Serial.print("read: \t\t");
Serial.println(scale.read());     // print a raw reading from the ADC


Serial.print("read average: \t\t");
Serial.println(scale.read_average(20));   // print the average of 20 readings from the ADC


Serial.print("get value: \t\t");
Serial.println(scale.get_value(5));   // print the average of 5 readings from the ADC minus the tare weight (not set yet)


Serial.print("get units: \t\t");
Serial.println(scale.get_units(5), 1);  // print the average of 5 readings from the ADC minus tare weight (not set) divided
            // by the SCALE parameter (not set yet)  


scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
scale.tare();               // reset the scale to 0


Serial.println("After setting up the scale:");


Serial.print("read: \t\t");
Serial.println(scale.read());                 // print a raw reading from the ADC


Serial.print("read average: \t\t");
Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC


Serial.print("get value: \t\t");
Serial.println(scale.get_value(5));   // print the average of 5 readings from the ADC minus the tare weight, set with tare()


Serial.print("get units: \t\t");
Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided
            // by the SCALE parameter set with set_scale


Serial.println("Readings:");
pinMode(driverPUL, OUTPUT);
pinMode(driverDIR, OUTPUT);
attachInterrupt(digitalPinToInterrupt(reverseSwitch), revmotor, FALLING);
}


voidloop(){
stepper(pd = map((analogRead(spd)),0,1023,2000,50)
(digitalWrite(driverDIR,setdir)
(digitalWrite(driverPUL,HIGH)
(delayMicroseconds(pd)
(digitalWrite(driverPUL,LOW)
(delayMicroseconds(pd))


Serial.println(A0);
Serial.print("Reading:\t");
Serial.print(scale.get_units(), 0);
Serial.print("\t| average:\t");
Serial.println(scale.get_units(1), 1);
}
 
Here is the error message. 
image
 
 

   
ReplyQuote
The apprentice
(@the-apprentice)
Member
Joined: 4 months ago
Posts: 61
Topic starter  

The load cell works perfectly but the stepper turns 1 rotation every hour. lol. I'm getting a reading of 14 on A0 pin thru the serial monitor. That is the problem I'm sure of it. I need to get the potentiometer to set the volts higher. If I turn the pot there is no change. Volts stay at .86. This means the UNO is at the lowest speed. 

image

This is my interpretation of things. I would like to thank every on for there valued input. I try everything that is suggested. Some of the comments are above my fire place but try I try. 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@the-apprentice 

As I explained a couple of pages ago, your motor will step only once per cycle through the loop.

Therefore, the time between steps will be pd PLUS all of the time taken to do the serial output. I think if you comment out the println commands that you'll see a marked improvement in motor speed.

 

PS the pot does NOT control the voltage to the stepper.

Anything seems possible when you don't know what you're talking about.


   
Inst-Tech reacted
ReplyQuote
The apprentice
(@the-apprentice)
Member
Joined: 4 months ago
Posts: 61
Topic starter  

@will The pot will give the UNO a reading in volts. That is how the UNO set the speed. 0V to 5V = 0 to 255. That is my thought? The volts to the stepper are controlled with the motor controller.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6982
 

@the-apprentice The reason it won't compile is it is gibberish. It is not C++ code or even C. What you post as 'the error message' is in fact one error message. Here are all your errors.

/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:13:17: error: no matching function for call to 'HX711::HX711(int, int)'
HX711 scale(2, 3); // parameter "gain" is ommited; the default value 128 is used by the library
^
In file included from /private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:4:0:
/Users/ronalexander/Documents/Electronics/SourceCode/Arduino/libraries/HX711/HX711.h:40:3: note: candidate: HX711::HX711()
HX711();
^~~~~
/Users/ronalexander/Documents/Electronics/SourceCode/Arduino/libraries/HX711/HX711.h:40:3: note: candidate expects 0 arguments, 2 provided
/Users/ronalexander/Documents/Electronics/SourceCode/Arduino/libraries/HX711/HX711.h:37:7: note: candidate: constexpr HX711::HX711(const HX711&)
class HX711
^~~~~
/Users/ronalexander/Documents/Electronics/SourceCode/Arduino/libraries/HX711/HX711.h:37:7: note: candidate expects 1 argument, 2 provided
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:14:1: error: 'unsignedlong' does not name a type; did you mean 'unsigned'?
unsignedlong currentMillis = 0;
^~~~~~~~~~~~
unsigned
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:15:1: error: 'unsignedlong' does not name a type; did you mean 'unsigned'?
unsignedlong stepperPreviousMillis = 0;
^~~~~~~~~~~~
unsigned
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:16:1: error: 'constunsignedlong' does not name a type
constunsignedlong stepperPeriod = 5;
^~~~~~~~~~~~~~~~~
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:17:16: error: expected constructor, destructor, or type conversion before ';' token
voidrevmotor() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:22:15: error: expected constructor, destructor, or type conversion before ';' token
voidstepper() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:28:13: error: expected constructor, destructor, or type conversion before ';' token
voidsetup() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:82:12: error: expected constructor, destructor, or type conversion before ';' token
voidloop() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:17:14: warning: ISO C++ forbids declaration of 'voidrevmotor' with no type [-fpermissive]
voidrevmotor() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:22:13: warning: ISO C++ forbids declaration of 'voidstepper' with no type [-fpermissive]
voidstepper() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino: In function 'int voidstepper()':
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:23:7: error: 'currentMillis' was not declared in this scope
if (currentMillis - stepperPreviousMillis >= stepperPeriod)
^~~~~~~~~~~~~
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:23:23: error: 'stepperPreviousMillis' was not declared in this scope
if (currentMillis - stepperPreviousMillis >= stepperPeriod)
^~~~~~~~~~~~~~~~~~~~~
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:23:48: error: 'stepperPeriod' was not declared in this scope
if (currentMillis - stepperPreviousMillis >= stepperPeriod)
^~~~~~~~~~~~~
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino: At global scope:
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:28:11: warning: ISO C++ forbids declaration of 'voidsetup' with no type [-fpermissive]
voidsetup() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino: In function 'int voidsetup()':
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:78:57: error: 'revmotor' was not declared in this scope
attachInterrupt(digitalPinToInterrupt(reverseSwitch), revmotor, FALLING);
^~~~~~~~
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:78:57: note: suggested alternative: 'voidrevmotor'
attachInterrupt(digitalPinToInterrupt(reverseSwitch), revmotor, FALLING);
^~~~~~~~
voidrevmotor
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino: At global scope:
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:82:10: warning: ISO C++ forbids declaration of 'voidloop' with no type [-fpermissive]
voidloop() {
^
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino: In function 'int voidloop()':
/private/var/folders/pg/mjb25hc97csf8q8j964tdfz80000gn/T/.arduinoIDE-unsaved2024118-75877-qpm7b.qd81wo/sketch_feb18a/sketch_feb18a.ino:87:16: error: void value not ignored as it ought to be
(digitalWrite(driverPUL,LOW)
~~~~~~~~~~~~^~~~~~~~~~~~~~~

Using library FlexyStepper at version 1.0.0 in folder: /Users/ronalexander/Documents/Electronics/SourceCode/Arduino/libraries/FlexyStepper
Using library HX711 at version 0.3.9 in folder: /Users/ronalexander/Documents/Electronics/SourceCode/Arduino/libraries/HX711
exit status 1

Compilation error: no matching function for call to 'HX711::HX711(int, int)'

I suggest you take a course on C. 

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
The apprentice
(@the-apprentice)
Member
Joined: 4 months ago
Posts: 61
Topic starter  

@zander LOL And here I was thinking I'm getting the hang of it. I'm sitting here all off my spare time trying to learn and I have noting to show. Is anyone up to building the code for me? I will obviously have to pay for it. I don't want to scrap this project.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6982
 

Posted by: @the-apprentice

@zander LOL And here I was thinking I'm getting the hang of it. I'm sitting here all off my spare time trying to learn and I have noting to show. Is anyone up to building the code for me? I will obviously have to pay for it. I don't want to scrap this project.

It's an undocumented rule of these kinds of forums that offers of money are not allowed. I think it's also in very poor taste to ask someone to write all the code.

You need to take a course in C, you don't even know the syntax rules. Then I would advise you do some basic stuff then maybe do a stepper project, then a load cell project and finally put the two concepts together. It's more difficult than you think. If you are doing this part time, it will take years.

I will tell you that when I worked at IBM when we hired university grads it took them two years (4,000 hours) to get promoted from trainee to associate. Some never made it any further, most made it to Programmer by year 5 but only a very tiny number made it past that.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Marvin
(@rob42101)
The Paranoid Android
Joined: 3 months ago
Posts: 32
 

Posted by: @the-apprentice

Is anyone up to building the code for me?

I've been following this thread (on and off) since I got here, as I too am new to this.

When I do get going, I'm going to be coding with MicroPython, not C.

I do have a head start, as I already have apx 5 years coding experience with Python3. That said, I still class my self as a beginner, albeit maybe an 'advanced beginner'.

I have coded C before, but Python is far easier, tbh. If you'd like a couple of resource, I can recommend at least two out of the hundreds that any internet search engine will return. The ones that I like, may not be what you like, mind: I'm a 'reader', not a 'watcher'.

Let me know if you're interested.

The only thing necessary for the triumph of evil is for good men to do nothing.


   
ReplyQuote
The apprentice
(@the-apprentice)
Member
Joined: 4 months ago
Posts: 61
Topic starter  

@zander Sorry for asking. Did not know. I'm just at the end of my line. I can not wait 2-5 years to make this work. I will have to look for something I have done before. I have built the whole machine from scratch using what Bill thought me. I never wrote the codes. Copy and paste it works. I have steppers/heat sensors/limit switches and speed controller's all working on the machine. I was hoping to use 1 UNO for controlling them all. I am much better at drawing and designing than coding. 

If I understand you correctly. Coding is for geniuses and it takes time?


   
ReplyQuote
Page 6 / 10