Show Posts
Pages: [1] 2 3 ... 23
1  Using Arduino / Motors, Mechanics, and Power / Re: Steppermotor and serial.print and read combined(Solved) on: August 03, 2014, 01:07:31 am
Hi Robin,

I could not get your solution to work with satisfaction.
So I went for a bypass.
2 x Nano
Nano1 to measure Position and Force
nano2 to control the stepper motor.
Two digital pins in between them to control the ON/OFF of the stepper motor.

Thanks for all the effort and time taken.

Paco
2  Using Arduino / Project Guidance / Re: HX711 24 bit ADC with four load cells on: July 12, 2014, 10:40:36 am
To use the channel B load cell, just change this line
HX711 scale (A1, A0); to --> HX711 scale (A1, A0, 32);

// put gain 64 or 128 to channel A, 32 for channel B
//You can not use both channels at the same time

So all the HX711 libs around do not support reading two loadcells in one loop?
So why technical speaking has this HX711 two channels if you cant read them in one loop and you have to change the call to the lib. which you cant do in a void loop.
Or should there come a LOOP code without the use of a lib?

Questions questions :-)

Paco
3  Using Arduino / Project Guidance / Re: HX711 24 bit ADC with four load cells on: July 06, 2014, 03:11:43 am
HX711 rework for higher sample rate.

For those who have the cheap green HX711 board and need the 80 Sps instead of the standard 10 Sps.
Take a sharp needle pin and put it under the PIN 15. Take a soldering iron with a fine thin tip and warm up the PIN 15.
As soon as the solder is melting little pressure on the needle pin can lift the PIN 15 from the board.
Then solder a thin wire from the PIN 15 to a VCC connection on the board.

This will give you 8 times more readings per second.

Enjoy
4  Using Arduino / Project Guidance / Re: HX711 24 bit ADC with four load cells on: July 05, 2014, 03:50:19 pm
Lib designer says in an earlier question from a user.

read the datasheet to see what i mean about the clock pin. you need to pulse it 24 times to get one reading (24 bits).

 
 // set the gain factor; takes effect only after a call to read()
 // channel A can be set for a 128 or 64 gain; channel B has a fixed 32 gain
 // depending on the parameter, the channel is also set to either A or B
 void set_gain(byte gain = 128);
  so use
  set_gain(32);
  to select the second channel, then read it. you can't read both channels at the same time. read the datasheet. then, use:
  set_gain(128); // or just set_gain();
  to select the first channel, and read it.
---------------------

set_gain(32) is throwing up and error set_gain was not declared.
So how difficult is it to read two channels????  :-)
5  Using Arduino / Project Guidance / Re: HX711 24 bit ADC with four load cells on: July 04, 2014, 11:49:05 am
Do not know if this works but according to the .h file the call for gain also set the channel.
Do not have the time to check.
Let me know or change the code so it works.

5-7-2014
I tested myself but it is not working!!!!!!!!!!!!!!!!

Code:
#include <HX711.h> // Github Bogde files!

// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0

HX711 scale(A1, A0); // 24 bit load cell amplifier

long ForceValueChannel_A = 0;
long ForceValueChannel_B = 0;
long emptyRead = 0;

/*
According to the .h file the call to get the A or B channel value is just set the gain after a scale.read call.
*/

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  set_gain(128); // takes effect after a scale.read
  emptyRead = scale.read();
  ForceValueChannel_A = (scale.read()/100);
  set_gain(32); // takes effect after a scale.read
  emptyRead = scale.read();
  ForceValueChannel_B = (scale.read()/100);
  
  Serial.println(ForceValueChannel_A);
  Serial.println(ForceValueChannel_B);
}  
6  Using Arduino / Sensors / Re: ENCODER, OPTICAL ENCODER ONLY GOING One way on: June 26, 2014, 04:28:18 am
try this code

Code:
// Interrupt information optical encoder
// 0 on pin 2
// 1 on pin 3
// works fine with 300lpi encoders

enum PinAssignments
{
  encoderPinA = 2,   // rigth
  encoderPinB = 3,   // left
};

volatile unsigned int encoderPos = 5000;  // a counter for the encoder
unsigned int lastReportedPos = 1;   // change management
static boolean rotating=false;      // debounce management

// interrupt service routine vars
boolean A_set = false;             
boolean B_set = false;

void setup()
{
Serial.begin(9600);// set baudrate for PC too!
  pinMode(encoderPinA, INPUT);
  pinMode(encoderPinB, INPUT);
 
 // turn on pullup resistors
  digitalWrite(encoderPinA, HIGH);
  digitalWrite(encoderPinB, HIGH);
 

// encoder pin on interrupt 0 (pin 2)
  attachInterrupt(0, doEncoderA, CHANGE);
// encoder pin on interrupt 1 (pin 3)
  attachInterrupt(1, doEncoderB, CHANGE);
}

void loop()

  Serial.println (encoderPos);

 
    rotating = true;  // reset the debouncer

  if (lastReportedPos != encoderPos)
{
    Serial.print("B,");
    Serial.println(encoderPos, DEC);
    lastReportedPos = encoderPos;
  }
 
// Interrupt on A changing state
void doEncoderA(){
  // debounce
  if ( rotating ) delay (1);  // wait a little until the bouncing is done

  // Test transition, did things really change?
  if( digitalRead(encoderPinA) != A_set ) {  // debounce once more
    A_set = !A_set;

    // adjust counter + if A leads B
    if ( A_set && !B_set )
      encoderPos += 1;

    rotating = false;  // no more debouncing until loop() hits again
  }
}

// Interrupt on B changing state, same as A above
void doEncoderB(){
  if ( rotating ) delay (1);
  if( digitalRead(encoderPinB) != B_set ) {
    B_set = !B_set;
    //  adjust counter - 1 if B leads A
    if( B_set && !A_set )
      encoderPos -= 1;

    rotating = false;
  }
}

7  Using Arduino / Project Guidance / Re: HX711 Weighing Sensor Module -> Returned Values are Fluctuating on: June 25, 2014, 08:37:50 am
1 kg and 50 kg loadcell need different weights to calibrate!
if you use 50 gram to calibrate  the 1 kg loadcell you might be fine for the tolerance of this loadcell.
Use 5 kilogram for the 50 kg loadcell. 50 gram to calibrate the 50 kg loadcell is much to low. TThe tolerance of the 50 KG loadcell is higher and you will not measure 49,99999 kg with the 50 kg loadcelll.
Use the bodge github HX711 libaray and read the instructions and first use the serial montitor then start to work on the LCD versions. If serialmonitor does not work (check the baudrates at arduino and serialmonitor first)

Paco
8  Using Arduino / Project Guidance / Re: HX711 24 bit ADC with four load cells on: June 23, 2014, 02:16:35 pm
Use the HX711  lib on Github made by Bogde.
Only use one loadcell and get it working.
Then add second load cell.

simple code with calibration inside the sketch not the .h file from the lib.

Code:
// Arduino with load cell
#include <HX711.h>

// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0

HX711 scale(A1, A0); // 24 bit load cell amplifier

long ForceValue = 0;

// Put two known loads on the sensor and take readings. Put those values
// here.
float aReading = 192.0; // put the value of the lowest rate here. 192 is a sample value
float aLoad = 500; // your lowest load value for example 500 grams or use no laod and take that value as lowest.
float bReading = 344.0; put the value of the highest rate here. 344 is a sample value.
float bLoad = 1000; // your highest load value for example 1000 grams

long time = 0;
int interval = 500; // Take a reading every 500 ms

void setup() {
  Serial.begin(9600);
}

void loop() {
  
  ForceValue = scale.read(); //
  float newReading = ForceValue;
  
  // Calculate load based on A and B readings above
  float load = ((bLoad - aLoad)/(bReading - aReading)) * (newReading - aReading) + aLoad;
  
  // millis returns the number of milliseconds since the board started the current program
  if(millis() > time + interval) {
    Serial.print("Reading: ");
    Serial.print(newReading,1); // 1 decimal place
    Serial.print("  Load: ");
    Serial.println(load,1);  // 1 decimal place, println adds a carriage return
    time = millis();
  }
}

9  Using Arduino / Project Guidance / Re: HX711 24 bit ADC with four load cells on: June 21, 2014, 11:46:26 am
Sofar I am still not in a need to read channel B too.
Reading four loadcells with the HX711 is for my next project.
But Always keen to know the results.

Paco
10  Using Arduino / Motors, Mechanics, and Power / Re: Steppermotor and serial.print and read combined on: June 08, 2014, 07:58:30 am
Quote
Shouldn't you have stepper.run() inside stepMotor() and nothing else.
stepper.runSpeed(); did the trick.
For testing purpose I just set maxTest to 100.
Motor runs and values of the force come in.

Quote
You seem to have chosen acceleration - that may interfere with what you are trying to do, take it out for now. And be sure to set the motor speed to match the step time that you want.

Acceleration line removed.

Thanks,

Paco
11  Using Arduino / Motors, Mechanics, and Power / Re: Steppermotor and serial.print and read combined on: June 06, 2014, 02:59:32 pm
Robin,

I changed the code to see how a real stepper would react instead of pulsing led 13 in the void stepperMotor()
So for the test I want to move the stepper in 180 degrees = 100 steps just to see if it works and if there is any motion.
But the stepper only steps one step per second with this code.

Paco

Code:
[/// this is just to test the understanding of using the HX711 and steppermotor

#include <HX711.h>
#include <AccelStepper.h>

// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0

HX711 scale(A1, A0); // 24 bit load cell amplifier

AccelStepper stepper(1,9,8); // set up the stepper as 4 wire bipolair on pin 8,9 for EASY DRIVER or other driver board

unsigned long startMillis;
unsigned long endMillis;
unsigned long currMillis;
unsigned long prevMillis;
unsigned long intervalMillis = 10; // do not change

byte maxTests = 100;
byte curTest = 1;

byte maxSteps = 100;
byte curStep = 1;

long scaleData = 0;

void setup()
{
  Serial.begin(9600);
  stepper.setMaxSpeed(3000);
  stepper.setSpeed(3000);
  stepper.setAcceleration(800); // do not remove!
  prevMillis = millis();
}

void loop()
{
  if (curTest > maxTests)
  {
    return;
  }
  startMillis = millis();
  curStep = 0;
  testTiming();
  endMillis = millis();
  curTest ++;
  stepper.run(); // does it block the 100 steps?
}

void testTiming()
{
  while (curStep < maxSteps)   // will loop through the steps at the speed set by intervalMillis
  {   
    currMillis = millis();
    if (currMillis - prevMillis >= intervalMillis)
    {
      stepMotor();
      prevMillis += intervalMillis;
      curStep ++;
    }
  }
  // now the Scale should be ready for reading
  scaleData = (scale.read()/100);
  Serial.print("B,");
  Serial.println(scaleData);
  Serial.print("A,");
  Serial.println(stepper.currentPosition());
}

void stepMotor()
{
  stepper.moveTo(100);
}
code]
12  Using Arduino / Motors, Mechanics, and Power / Re: Steppermotor and serial.print and read combined on: June 04, 2014, 11:37:00 pm
Next is to find out the touching point of the spring by the moving top plate. I hope I can find some time this evening to add some code and test it. One step furhter!

Thanks, Paco
13  Using Arduino / Motors, Mechanics, and Power / Re: Steppermotor and serial.print and read combined on: June 03, 2014, 11:41:43 pm
Robin,
Your correct about the two files showed.
My mistake. It seems I only make mistakes lately.
I forgot to upload the new sketch so the serial monitor showed same sketch.
This added file3.jpg with the serial monitor shows the values with lines commented out.
The value of the load cell is correct.
This just a raw value of the milivolts from the load cell amplified by the HX711.

Paco
14  Using Arduino / Motors, Mechanics, and Power / Re: Steppermotor and serial.print and read combined on: June 03, 2014, 01:04:21 pm
Robin,

Please do not be frustrated. Sorry if I made you feel that way. Not my intention.
I have limited time sometimes.
See the pictures.
One with the commented line the other without.
Also the added line for the serial print of the load cell does not change the timing reading.
Results for 20 readings all the same except for the first one.
The reading of the loadcell value also stays the same.

Paco
15  Using Arduino / Motors, Mechanics, and Power / Re: Steppermotor and serial.print and read combined on: June 02, 2014, 11:44:03 pm
Sorry for half info.

Code:
Do you mean that you changed the maxTests value from 5 to 100 and it still worked?

YES

Quote
I wonder if you mean that you lowered intervalMillis to 9 (not 90)?
YES and then the result is random between 89 and 91.
If I lower intervalMiliis to a lower value like 8 or 7 the random numbers are more and more varying in larger up and down values like 65 to 73 for 7 intervalMiliis value.
Quote
By "alll readings" do you mean with and without the scale.read() command?
did not changed the standard setting yet.

Quote
Did you get it to print scaleData so you could see if it is giving correct values? (I have no way to test that).
Will test this evening.

I let you know if I need more of your time :-)

Paco
Pages: [1] 2 3 ... 23