February 11, 2018 at 12:51 pm #52884
So each interrupt runs independently of each other and the main loop?
Check.February 11, 2018 at 8:18 pm #52928
AHHHHAHAHAHAAHHHHHH dang it. I could not figure out the led situation forever. I have a photodiode, tested it with the meter, seems good, a bag of 200 UV leds and all sorts of other ones. Nothing worked. My buddy sparked a lighter at it…works, like works in the rpm code even. So I can only guess that they were not a matched pair as in my photodiode isn’t tuned to the same 395nm as my UV LED’s? Ordered the matched set from the instructables article, so on hold until Tuesday.February 12, 2018 at 8:04 am #52948
Awesome, awesome progress man! I’m really happy with the Makita so far with it’s manual speed range settings, but I would definitely look at giving this a try once it gets developed.February 12, 2018 at 8:08 am #52949
As far as I know anything with a built in speed adjust has to be hardwired without it. I have no idea if just setting it to 100% works but I will look into it more when/if this works.February 12, 2018 at 8:22 am #52951
I have one Makita and two of the copycat Rocky 30 routers, I’m willing to take one apart and try this in the name of progress!February 12, 2018 at 9:50 am #52969
As far as I know anything with a built in speed adjust has to be hardwired without it. I have no idea if just setting it to 100% works but I will look into it more when/if this works.
Yeah, this is interesting. I wish I knew more about it. There’s an interesting story there. I imagine it like two pairs of polarized sunglasses, varying in phase, but I doubt it’s that simple.February 12, 2018 at 10:03 am #52973
Holy cow, have you seen what happens with three polarizing filters?? Blew my mind. I gotta find it.February 12, 2018 at 10:04 am #52974
Sorry for going off topic but that doesn’t sit right with me.February 12, 2018 at 10:15 am #52977
So, as long as you put another Triac in there, it will be fine.February 12, 2018 at 10:19 am #52979
Maybe right, All those semesters of physics….I feel like I was lied to. So crazy.February 15, 2018 at 1:35 pm #53168
Okay the RPM seems to be getting read but the numbers are off by what I would guess is 10k rpm meaning what I would expect to be 30k is reading as 40k dirty signal though, pretty dam hard to get a good reading. I am going to grab a optical tachometer from HF to try and verify some numbers.February 15, 2018 at 2:49 pm #53172
The optical is giving me 20, 400 to 29,500 with my store bought speed control. Sweet numbers to work with and even it works best at an angle and not straight on.February 15, 2018 at 4:20 pm #53174
Are you timing rising edge to rising edge? Rising edge to falling edge would have more error, I think.
I’m not sure what you meant in your second post.February 15, 2018 at 5:10 pm #53175
Sorry, I was kinds jotting down notes/making an update.
I don’t think optical reflection is that safe of a indicator. The clean reading point is small and I think ambient light has a lot to do with the interference. I would much prefer an optical encoder style disk. I have nice pre-made all in one sensor and receiver boards and I think that is going to be a much cleaner signal. Hopefully a disk can be 3D printed, but there are tons of issues with that as well. http://amzn.to/2EvyBDp
The second message was just me buying an actual rpm tool and verifying the readings.
Another option would be to put a dot on the cooling fins of the 660 and get the readings from that. It is dark and a better target but the dust build up would probably make it a bad choice.
Attachments:February 15, 2018 at 5:12 pm #53178
The comments are just me keeping notes. Using unsigned long just in case there was some sort of math error but a volatile word is the correct option here I think.February 15, 2018 at 5:47 pm #53179
Dang it…I see what I did wrong there, that is still for pwm timing. I just need time between falling. Explains the 10k RPM off, doen’t fix the crappy signal.February 15, 2018 at 6:22 pm #53182
Using the sensor board and the encoder the readings are super consistent, +- 10-15rpm @20k with many repeat readings! Super sketchy holding a router with a spinning disk and a small pcb in both hands…
Attachments:February 15, 2018 at 7:49 pm #53185
Are you wearing safety squints?
You can use just the one callback to handle the RPMs. If you don’t have a good reason not to, just use ints for any integers. Bytes are mostly just for storing characters and words aren’t really used for anything.
The next thing we could add, since we are literally getting a measurement every 3ms, is to do some low pass filtering. It will make the response slower, but the reading smoother:
smoothed_rpm += ALPHA * (rpmmath - smoothed_rpm);
ALPHA goes from 0-1, at zero, the value never changes, at 1.0, it just copies the input. For this math, you need to just use floating point numbers.February 15, 2018 at 8:26 pm #53187
It took me a while to understand the other ISR(? void functions). I kept think how the heck is this doing three freaking loops at the same time. About and hour ago it clicked. Only the void loop is looping, the other two ISR(?) are running once (independently, I get that) and calling each other perpetuating a loop only if the interrupt triggers a falling condition. I kept thinking the loops where piling up or something.
I feel like such a schmuck but it has been a while for fresh coding and never involving interrupts.
I understand your code and need to try it. I had already realized the need for long’s.
This is pretty fun, I do like the logic part of it. I couldn’t work out how to get the two different times in the same ISR(?) your solution makes total sense.
So how does the time work (micros), is there ever a need to zero it out? I mean 8 hours or run time could result in a giant number. Will it roll over at some point? I kept trying to loop it and zero it out each loop.
This is weird that I have questions but not the right language to ask it in. Fascinating, really, I feel like I am on a bus in a foreign country and don’t know the language. I know what I want just not how to ask properly. Each little piece of info is a minor triumph.February 15, 2018 at 9:54 pm #53193
Aargh. I had a big post and somehow deleted it while trying to format the code in it. Did it email itself to you?February 16, 2018 at 8:17 am #53198
Yeah I got it. Quoted below so everyone can see the info.
So how does the time work (micros), is there ever a need to zero it out?
It is an unsigned long, which is 2^64 on an Arduino, I think. It starts at zero when the processor boots. 2^10 is 1024, so you have about 2^44 seconds. There are 525,600 minutes in a year (thanks Rent!). So 30M seconds/year. So that’s about 2^19 years? I wouldn’t worry about it. The brushes on the dewalt are not going to last as long as those 64 bits.
This is weird that I have questions but not the right language to ask it in.
It really is strange. Anthropologists should be studying the whiteboard meetings between software engineers. I would really like to know why some things are so easy to explain in programming but hard in English. Plus, when you’re starting out, you don’t know what the algorithms are called.
Glad you’re enjoying it. Just remember how many hours you have burned in CAD and design and don’t expect to immediately have success in software. It takes practice, like anything else. I’ve put in my 10,000 hours, but I still have to look stuff up all the time and the computer is constantly complaining about my work. 🙂 You’re doing great already.
Only the void loop is looping
The loop() is an Arduino specific thing. I don’t know why they did that, but normal c++ doesn’t have a setup or loop. In Arduino, they basically add this to the very end of the code:
ISR is an “interrupt service routine”. And that tells you exactly what it does. The hardware actually stops execution of the main code, and goes to “service” that interrupt. The ISR is running whenever the physical hardware senses the change, and it stops whatever else is running. That’s why you don’t do much work in the ISR, because nothing else is happening as long as it’s running (including other ISRs). So when the hardware detects that falling edge, it will quit printing to the serial port (as an example), and copy the micros out. If you were doing something really slow, then it might miss timing on the serial port or something. The attach call resets the interrupt to fire again. I moved it to the end because I’m paranoid, but you don’t want the interrupt to fire while your still in the ISR.February 16, 2018 at 8:29 am #53199
Everything I know about programming I learned from arduino’s build in examples, and you! Even the crazy programming courses I had to take in school were not broad focus, it was more about how to program an equation. Excel is harder to do math in and we had to learn that in Chemistry 1.
This Interrupt thing, feels like you gave me a key to something huge. Again a million thanks for your patience and guidance.
Back on track.
The encoder disk is such a clean signal I don’t it is even worth it to try to do it any other way. I will continue with it and the other way will always work if we can figure out a better way with the reflection thing. The reflection is also picking up a ton of electrical noise so it needs some sort of filter. This was mentioned in the Instructables thing about his OLED. So far the encoder board is clean and I feel much safer way to play with mains power control.February 16, 2018 at 10:58 am #53213
Just wanted to say I like the work you are doing on the speed controller.
Keep up the good work.February 16, 2018 at 12:45 pm #53215
No, it is not the final design, this is just to keep my fingers a little further away. The actual mount will need to get tucked in real good and be able to swing out of the way I think, I would love just epoxy a disk to the top end of the shaft.
Now….let the real programming begin. First a little speed control test. Might try top get a video snippet of it. Then figure out some PID stuff.
Attachments:February 16, 2018 at 1:46 pm #53222
Crap, Sh%t, #$%^&#$%^*(V @#)#%$*@#.
I think the speed control died. I have no idea what happened. Tried to put the 660 on it, nothing, and then out of the blue full speed. Nothing but full speed since. I guess that was the wrong part.February 16, 2018 at 2:50 pm #53227
Even with the control powered off it is still running the power and it didn’t do that before. I really have no idea what happened but I ordered new triacs for that board, and a new board.
And I got a face full of that encoder while while it happened, so that isn’t a good idea.February 16, 2018 at 3:50 pm #53232
Whoa! The encoder flew off or your printed part?
If you can dodge an encoder, you can dodge a ball.
Maybe we have to go back to the HF speed control with a servo moving the knob.February 16, 2018 at 3:57 pm #53233
Maybe we have to go back to the HF speed control with a servo moving the knob.
BOOOO! Maybe, but I am not giving up so quick. That board though, I do not like how it dies wide open….It could have been my fault I used two different outlets, maybe I was on separate circuits?
The printed part popped in half. I knew the split design wasn’t the best idea but it was fast to CAD. Got my hand and my face….Safety squints from now on. You tried to warn me.February 21, 2018 at 10:35 am #53488
The new triacs work! So just tested the simple speed control for the rambo, M3 s15000 and m4, work! The router spins at real low power even, of course I haven’t test the strength but it is promising).
It is a bit disturbing though when I plug in the dewalt to the triac board I do get a usb disconnect and reconnect…..powered off. I will leave it alone for now because of the rat nest of wires could be an issue and I can just say before turning anything on make sure the router is plugged in.
So back to integrating the encoder side.February 21, 2018 at 11:06 am #53490
Okay the speed sensing and speed control are on the same nano and working. That is a great step.
So we have a gas pedal and a speedometer. Now refine the logic a bit, and then start working on the cruise control (PID).
You must be logged in to reply to this topic.