Notifications
Clear all

Stepper and load cell

150 Posts
8 Users
31 Reactions
6,680 Views
The apprentice
(@the-apprentice)
Member
Joined: 9 months ago
Posts: 67
Topic starter  

Maybe Bill must do a basic coding course. The way he presents his videos are great for me. If he had the time to do so. Not sure. 

Thanks to every one that is trying to help. I will look at all you suggested and see what works for me. 


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

@the-apprentice If you decide to code in C then I recommend the following, every C programmer I have ever met started with this book. If you choose Python I can't help, but I am sure our resident Python expert @byron will steer you in the right direction.

Here is the C book link on Amazon https://amz.run/8gvl  

It's remotely possible you may run into some C++ code but I don't recommend taking the course for that as we seldom actually get involved in it, it's more for library developers. If you do, just post any questions about the C++ part and someone will help.

One of the best references for the ESP32 processor is HERE. It covers all the features you may need like timers, interrupts, tasking etc. I don't know of a similar reference for any of the Arduino boards as there are so many but the ESP32 is more than capable.

Virtually all the example sketches you have ever seen are dealing with a single external entity unless there are multiple I2C devices (not applicable to your project) but your project has 2 very incompatible devices. I think there is a fairly simple way to do it, but so far I haven't had the time to research it. I may check a few things out later today so stay tuned.

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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Inst-Tech reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1859
 

Hi @the-apprentice,

Re: Maybe Bill must do a basic coding course. 

I am sure that if he wished to, Bill could produce some excellent coding courses, but you can also consider alternative courses that are presently available.

-------------

Finding tutorials and references that match your style of learning is something only you can do personally, but as a start, you might try Paul McWhorter aka toptechboy

e.g. Python Tutorial 1: Introduction to Python for Absolute Beginners at

and ...

Using an Arduino with Python LESSON 1: Introduction, Prerequisites and Class Gear   at

-------------

Note that projects like yours, with microcontroller, peripherals, programming, multitasking, control, etc. use a wide range of skills and experience. In a commercial environment, this will often be tackled by a team of appropriate specialists. That does not mean a single person cannot be competent in a range of skills, but it involves a lot of learning, some of which may appear in different environments, and explained by different people.  For example, the first of the references is based on a PC, but much of the material will also be relevant to a microcontroller environment.

Best wishes, Dave


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

This is not even close to a commercial project. I think most of you here will have a good laugh if you see my setup. The red x is where the load cell needs to be. Tension here must slow the stepper driving the winder spool. 

 

Pultruder

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

Posted by: @the-apprentice

This is not even close to a commercial project. I think most of you here will have a good laugh if you see my setup. The red x is where the load cell needs to be. Tension here must slow the stepper driving the winder spool. 

 

-- attachment is not available --

@the-apprentice, Very good, nice setup.. now we can see and understand what you are trying to do..

I'm put together a working model of the load cell and running a 28BYJ-48 unipolar stepper motor with a ULN2003 driver..I also have the A4988 driver, but I'm still waiting on my NEMA17 Bipolar stepper motor to arrive so I can test all the hardware that you said you were  using. The rendition that I'm running causes the motor to speed up when the load increases, but that's a simple programming fix..I just wanted to make sure that the hardware and motor would do what you specified..it does.. I will work up a schematic and wiring diagram, and post the sketch when I through testing.. Keep at it, your almost there...lol

Regards,

LouisR

 

 

LouisR


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

@inst-tech Was thinking of using a STM 32 Nucleo. It can multi task. Do any one know of this processor?


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

@the-apprentice Lot's of MPU/MCU can multi task including what you already have, why do you think that will help?

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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


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

@the-apprentice Where you placed the red x for the load cell does not look like it would work. You need to 'measure the tension, so something directly in front of the takeup spool makes more sense. You will need an anchor point for one side of the tension gauge, and the other side must be connected to a pulley so the string can exert pressure on the strain gauge. This is the hard part of the project.

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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


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

@zander Not sure if it would. That's is why I'm asking. I was under he impression the Arduino would not do this task. Was looking at esp32 and and. I just want this to work. Don't want to trough 1.5 years of building away because I cannot get the stepper to stop breaking the plastic tread. Like I said previously. I'm using bottles not for the $ you save. It is not easy to print with and not cheep at all. It takes time to tread the bottle and I am doing everything with solar. It keeps me busy. It is interesting all I have gone true since starting with my Ender5 way back. I have always loved electronics and meeting Bill was my first step in really doing things. (That actually works) It has been a ride and I'm never falling of.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1859
 

Hi Ron @zander@the-apprentice,

Re: You need to 'measure the tension, so something directly in front of the takeup spool makes more sense.

I agree that the dynamic operating conditions are not completely clear from the photo, but it appears that the pulley marked with the X is exerting a sideways force on the fibre, so that the tension will exert a force that should be proportional to the tension, and hence usable as a control input.

The part that is unclear to me is whether the sideways angle will change if the fibre moves sideways across the end roller, as I might expect the measured force will be sensitive to fibre angle changes at the tension sensing pulley. I realise the direction of the feed to the roller is partly constrained, so maybe my concern is invalid.

Best wishes, Dave

 


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

@zander I have done my calculation and at that point you can get from250 to 1Kg. It is out of the way and not impairing the feeding of the read when you load the system. There is another roller just in front of the spool winder but it is in the way when loading. The fitting of the load cell is easy. Like I explained with the printer anything can be done. To design the bracket is what I'm good at.


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

@the-apprentice I am not 100% sure what you are asking, but you are probably confusing multi-tasking with multi-processing. I used to work with hardware/software that was both multi-tasking and multi-processing. Multi-tasking just means that you have two 'threads' or tasks that alternate. This can be done just using a timer function like millis or installing an OS like RTOS and several tasking libraries in between. The code that I and others have shown you so far are all multi-taskiing.

Multi-processing does mean several programs running at the same time. I used to manage a system with 6 logical CPU's and each had from 4 to 16 tasks. This was a beast for multi work as it used pre-emptive multi tasking, not co-operative. That means I as the 'operator' could externally control how many time slices and of what duration and priority any one task received.

To hopefully give you some perspective, if we assume the load cell takes 100 milli-seconds to return a reading as I believe it does, and lets assume the MCU you are using (esp32) takes 100 micro-seconds for the empty loop (probably closer to 10 in reality) then the load cell IF blocking takes up 1,000 loops worth of time per loop. The key is whether the load cell call is blocking.

I extracted the load cell code that actually reads the values. It actually uses tasking as you will see. I deleted a lot of code to do with the details but just the highlights and comments should give you a clue.

Here are my clues

BLOCKING takes most time

yield() (this is a tasking call)

noInterrupts (what the code is about to do MUST not be interrupted, in other words a tasking block)

digital reads and writes all take time and the Espressif docs on ISR design strongly recommend against using them inside the ISR, the mantra is set a flag and exit, so although this code is not an ISR, it is time critical code so it hogs the processor and disallows any interruptions.

SO, what Louis is going to determine is if the stepper can be told to keep running at a set speed while the slow load cell gets a reading. This reading can then be used to modify the stepper speed up or down.

It may be doable, but it is a little risky which is why my #1 approach would be to use 2 esp32's, one getting load cell/strain gauge values maybe averaged over some amount of time and then sending a correction factor to another esp32 that is controlling the stepper. I think using analogue write and read will be the easiest method of speed control. One advantage of this plan is you can test with a pot on the read side (stepper speed control) as the esp32 could care less if it's a pot or another esp32 doing an analogue write.

 

float HX711::read()
{
  //  this BLOCKING wait takes most time...
  while (digitalRead(_dataPin) == HIGH) yield();

  //  blocking part ...
  noInterrupts();

 lots of nitty gritty bit banging

  while (m > 0)
  {
    digitalWrite(_clockPin, HIGH);
    digitalWrite(_clockPin, LOW);
    m--;
  }

  interrupts();

  //  SIGN extend
  if (v.data[2] & 0x80) v.data[3] = 0xFF;

  _lastRead = millis();
  return 1.0 * v.value;
}

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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


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

@the-apprentice

@zander I have done my calculation and at that point you can get from250 to 1Kg. It is out of the way and not impairing the feeding of the read when you load the system. 

Ok, I will take your word for that, it's difficult for us to know the workings of your machine in the detail that you do.

BTW, are you related to Rube?

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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


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

@zander Don't know Rube why?


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

@the-apprentice Sorry, that was a (poor) attempt at a joke. Never mind.

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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Page 8 / 10