Notifications
Clear all

Stepper and load cell

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

@byron @the-apprentice Not even close to a sermon and much more readable.

Sorry Byron, most of this post is actually directed at the OP, but I also am talking about the learning issue especially as to how choice of language is somewhat irrelevant.

I wanted to point out something that has been overlooked (due to insufficient investigation by some), namely that the load cell code is using tasking and critical section techniques in order to NOT hog the CPU. Other than writing the dozen or so lines of main loop code needed for this project (did it in pseudo code earlier) I can't be more specific in guiding the OP. The stepper code is ONE LINE of code in the main loop!!!!! Plus a tiny routine to 'adjust' the stepper speed to accomplish what the OP wants.

Here is the clue.

// this BLOCKING wait takes most time...
while (digitalRead(_dataPin) == HIGH) yield();

Better communication skills on the part of the OP would move this project to completion in a few hours but he seems reluctant to participate.

Surely I don't need to spell out what participate means in the context of a forum involved with code do I???

As many of you will know, I am of the school that believes in teaching the man/woman to fish, I don't hand out fish although in this case I have darn near already done that. It's 2 samples from the relevant libraries that have to be logically married then the addition of a pot driven speed adjuster (1 line of loop code to create (2 lines if not using nested functions), and 1 line of code to make the adjustment)

When learning to program the first skill that you need to learn is how to communicate in order to make your needs known, and to understand what your end user needs from the proposed code you are preparing to write. All that comes before learning about number theory, boolean logic, state machine theory and the other minor skills needed prior to learning the difficult stuff.

Learning a specific language syntax is the most trivial part of being a programmer, whereas learning the underlying principles (like when to use int or float, or when to use for or while etc)  is much harder.

In the following post is the pseudo code (actually more like an outline, but you get the idea) https://forum.dronebotworkshop.com/help-wanted/stepper-and-load-cell/paged/9/#post-46295

then in the post following that is the one line pot reading code. All that you need to figure out is what to do with the 'newSpeed value. NOTE: you MUST treat this as a delta, NOT an absolute.

Ok, I will give you this freebie. What I mean by delta is the speed at time T where T is not close to 0 the speed is controlled in small increments by the load cell. IF the human operator decides that the speed can be higher, then adjusting the pot + adds the delta between new pot speed and old pot speed to the load cell calculated speed (if adjusted in the other direction, then subtract or add -ve values). Use a linear pot, and position it when power is off to approximately the middle of it's range, that way you can adjust both + and -. I suggest you experiment with differing map values so that all conceivable pot speed values represent the foreseeable range of values needed in the real world.

Since I do not have a feel for the tension the plastic string can withstand I can not help with the default stepper speed nor the map values needed to achieve fine control. The OP will need to conduct a small series of simple experiments to determine these values.

It should be obvious, but the OP will need to deal with starting the entire machine from zero to whatever speed is nominal. I suggest a slow ramp up and do that in the setup code before dropping into the main loop. Obviously then the main loop must be built with the assumption of a steady state speed and the load cell makes minute adjustments with the pot making larger adjustments. He could even have a coarse and fine pot. I leave how to do that as an exercise for the reader.

And that is how one sermon begets another sermon.

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 and DaveE reacted
ReplyQuote
The apprentice
(@the-apprentice)
Member
Joined: 4 months ago
Posts: 61
Topic starter  

Better communication skills on the part of the OP would move this project to completion in a few hours but he seems reluctant to participate.

Surely I don't need to spell out what participate means in the context of a forum involved with code do I ???

Ron This is my hobby. Work is first and when I have time I like to fiddle with my projects. Sorry if I don't know how to use  forum. Tel me what you need and I can supply the information. 


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

@the-apprentice What I and anybody else needs is a better explanation of 'doesn't work'.

Obviously paste into the <> source tool the EXACT copy of the code involved. Accompany that with an explanation of what should have happened, and what did happen.

Be prepared to answer questions and/or make changes as suggested by any member trying to help. It is a fairly big problem if after you post as I just suggested you then go off and modify things. That is just a waste of time for both of us.

Your code at this point should just be the two sample sketches 'married' and the addition of stepper ramp up code in the setup section plus pot driven delta speed adjustments in the loop section, otherwise the sample code is good to go with whatever changes are needed for your hardware.

Clear?

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  

Thanks for the explanation. My reply's will how ever be delayed as I don't always have time to work on it. Thanks to every one that have helped. 


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

@the-apprentice You are very welcome, I look forward to seeing your completed project. I will compare your code to mine (yes, I did finish it) to see how well the apprentice did.

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  

Lol Just to see if I'm trainable? I'm sure there will be a ferry faint light at the end of the tunnel. 


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

@the-apprentice I am not sure if it will make you feel better or worse, but becoming a good programmer is a lot like becoming a good pianist. Almost anyone can learn what notes to push, but only a rare few make it sound like music that moves your soul.

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 now decided for this project I will move to where I'm good. I will make the speed control mechanical. I will use gearing to set the potentiometer and control the motor speed. 

I will keep on with the code but I need this machine to run now. I have broken so many gears that I can now open a broken gear scrap yard.  😛 


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

@the-apprentice Before we had electronics, they did it with mechanical means in the steel industry and paper industry. It's a long time ago, but basically you set up a way to have a big hanging loop, or a series of back and forth horizontal loops. Simple spring tension or even just gravity aided initially by a human then later some sort of mechanical feedback system before they went electronic. It can be done.

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'm using a simple gear and lever system. This turns the potentiometer with a gear in place of the nob. 


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

@the-apprentice Whatever, that sounds like a manual control. You should be able to create a hanging loop then adjust the pot so that the pickup speed matches the delivery speed. You will also need some sort of switch like a micro switch to detect the end of a run and that kills all power (after some small amount of time to allow for the least wastage)

It just occurred to me, you need two pots, one controlling the stepper that pulls the string off the cutter head, then to a loop, and another pot that controls the speed of the take up reel. If you can understand what I mean and mechanically build that plus I assume you are able by now to write the stepper motor sketches )just two MCU (esp32?) a copy of the 3 line stepper sketch then add the line or two needed to utilize the pot.

Once you have that working manually, I think there is a couple ways to automate that without the strain gauge.

Keep us informed.

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  

Eventually got time to waist again. Made a small gear and rail. Pot now controlling the speed of the take up drum. The main puller speed is not an issue as the take-up drum pulls on the filament and this will cause it to grip and pull the filament. I have noticed a bit more speed on the main puller is better. I broke the main take-up drum support when I striped the stepper out. Now busy printing another one. 17 Hours to go. I will post a new video when it is assembled and working again. 


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

@the-apprentice I think you should change your nickname to McGuyver and name your machine a  "Rube Goldberg machine"

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.


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

Some of my friend have commented that I will engineer thru a problem not around it.


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

It works. Thanks to everyone that helped. You are great. 


   
DaveE and Inst-Tech reacted
ReplyQuote
Page 10 / 10