#avr Logs

Feb 09 2018

#avr Calendar

12:06 AM nuxil: it only does upto ~20V . because the trafo has a center tap. and if i use the +/- 15 rail i get 30V ac * sqr(2) ~42V dc. the module can only do max 40 on input. and i dont want to keep it on the limist.
01:04 AM rue_: nuxil, "Your browser is not supported in Gyazo. Not all features are available in this browser. Please use a modern browser such as Google Chrome."
01:04 AM rue_: :(
01:04 AM rue_: I suppose the site cant show an image using less than html5
01:04 AM rue_: maybe the ads require features I dont have
01:04 AM nuxil: update your browser :p
01:07 AM rue_: no!
01:07 AM Casper: I will update my browser when they will allow tab modification...
01:07 AM rue_: I like browsers that have a menu bar and behave
01:07 AM rue_: chrome dosn't close when you close it
01:07 AM rue_: it keeps a thread going in the background
01:08 AM rue_: keylogging maybe
01:08 AM rue_: ;)
01:08 AM Casper: chrome is a malware magnet
01:08 AM rue_: and its bloatware
01:09 AM rue_: its 6x slower than iceweasel... (firefox)
01:09 AM Casper: seriously, I remove malwares for a living, i.e. have some, firefox rarelly have anything, chrome is full
01:53 AM tylerl: is there a macro that compiles to the bset and bclr instructions? Eg: "bset DDRB,4" instead of DDRB |= _BV(4)?
01:54 AM tylerl: turns out that setting the whole register is causing something like a crash if it happens during an i2c operation.
01:56 AM tylerl: hm. bset it's the right instruction, it only operates on SREG...
01:58 AM tylerl: ah, CBI and SBI is what I'm after. now to more googlez.
01:59 AM rue_shop3: tylerl, did you read the topic?
01:59 AM tylerl: yup, and it's totally the thing that I am not looking for
01:59 AM rue_shop3: I should just have a bot post those macros every 2 hours
01:59 AM rue_shop3: it does resolve to sbi and cbi
01:59 AM rue_shop3: unless you use it on a memory location, cause you can do that
02:00 AM tylerl: So... why does your topic say it's defined as (PORT |= 1(<<BIT)) ?
02:00 AM tylerl: that's that thing that doesn't work.
02:01 AM rue_shop3: hu?
02:01 AM rue_shop3: show me how your using it
02:01 AM rue_shop3: cause, if your doing it in a sane way, it works fine.
02:02 AM tylerl: i'll clean up the code a bit and gist it
02:13 AM tylerl: here you go: https://gist.github.com/tylerl/2f03d4d45e035ca7f38657492483be6f
02:14 AM tylerl: the problem is that sending i2c commands during the loop creates a lock-up condition waiting on the SetBit/ClearBit operation.
02:15 AM tylerl: Since I2C is on port B on the tiny 2313, i'm indirectly poking the i2c pin mode when I set DDRB, which I think is the problem.
02:16 AM tylerl: but since avr has an instruction that pokes a single bit, not the whole register, I want to use that instead to hopefully *not* get the same result.
02:17 AM tylerl: The problem may be that I'm passing a variable instead of a constant as the bit location into SetBit; could be that the compiler only subs the alternate assembly in if you use a constant.
02:19 AM rue_: there is no wait for setbit or clearbit
02:19 AM rue_: you trying to READ the bit?
02:20 AM tylerl: hm. looks like I was right. Replacing "SetBit(which, DDRB)" with "switch(which) { case 0: SetBit(0,DDRB);break;case 1: ....." fixes it.
02:21 AM tylerl: silly, but there you go. So nifty future reference for you.
02:21 AM rue_: ah, yea
02:21 AM rue_: your trying to use it with a non-static bit, so it wont compile to just sbi or cbi
02:23 AM rue_: I wonder how it tried to deal with that
02:23 AM tylerl: right... because cbi and sbi can't reference a register for the bit location.
02:23 AM rue_: correct
02:23 AM tylerl: /sigh.
02:23 AM rue_: it would probably read it and do the bitwise, but I cant see why that would hang
02:28 AM tylerl: That's not entirely clear to me either.
02:29 AM tylerl: But it's exceptionally reproducible. I rigged up another avr to send i2c input once ever 10msec, and the condition gets triggered within seconds.
02:33 AM tylerl: I think... I think I might know why.
02:35 AM tylerl: I2c changes pin modes pretty rapidly since a single pin does both input and output. And since the read-modify-write pattern for non-static "REG |= (var)" instructions isn't atomic....
02:36 AM tylerl: so it could be setting the pin mode back to write when it's expecting to be read, which could cause the interrupt handler to stall waiting for inupt. or something like that.
02:41 AM tylerl: final version up at https://gist.github.com/tylerl/2f03d4d45e035ca7f38657492483be6f -- this one works perfectly.
03:22 AM Emil: >Arduino.h
03:22 AM Emil: staph
03:24 AM -!- #avr mode set to +o by ChanServ
03:31 AM rue_bed: so, when will the spambot get here?
04:49 AM polprog: rue_bed: didnt it already? i remember it i think
05:26 AM rue_bed: it was going around again
05:26 AM polprog: i dint remember if i asked, did you get the makefile?
05:27 AM rue_bed: I think I had you hold onto it cause I was just gonna lose it
05:27 AM rue_bed: stm32 right?
05:27 AM polprog: yeah
05:27 AM rue_bed: I'll do more stm32 in a while
05:28 AM rue_bed: building a 3d printer and playing with comb filters right now
05:33 AM polprog: ive got this teac stepper, but im trying to figure out how to drive it.. i found it has two phase coils. how does that work?
05:33 AM polprog: http://wiring.org.co/learning/topics/imgs/StepperMotor.png
05:33 AM polprog: wiring etc matches
05:39 AM polprog: looks simple enough
05:40 AM polprog: ill try to put something together
05:45 AM rue_bed: bipolar, you need a dual H bridge driver
05:45 AM rue_bed: have an A4988 driver?
05:46 AM rue_bed: L293 is ok, but will suck to a large degree
05:47 AM rue_bed: and the A4988 reprap drivers are probably cheaper
05:47 AM rue_bed: OOOOh, I get it, I must be pre-ill and thats why I cant sleep
05:47 AM rue_bed: damn
05:49 AM rue_bed: almost 4am, alarm clock goes off at 6, I'm screwed
05:55 AM polprog: bipolar you say
05:55 AM polprog: damn i thout it was not
05:55 AM polprog: well, ill take a look at that driver then
05:55 AM polprog: i dont think theres any reason to make 2 h bridges out of mosfets
05:57 AM polprog: thanks
05:57 AM polprog: that looks like a neat stepper motor. solid one
06:01 AM polprog: wait, its unipolar
06:01 AM polprog: http://mcs.uwsuper.edu/sb/Electronics/Stepper/
06:01 AM polprog: see pic
06:32 AM rue_shop3: no
06:32 AM rue_shop3: by bipolar I mean "can reverse polarity"
06:32 AM rue_shop3: the A4988 is cheap ($1) and can do current control which lets you do microstepping
06:33 AM rue_shop3: atleast 4x microstepping will help the torque of the motor
06:50 AM polygon: polprog: if you have an mcu then you can use 4x irf7307 to make 2 full bridges, needs 8(4) ports
06:50 AM polprog: aha
06:51 AM polprog: well that one is probably broken i measured resistances on the pins, take a look. I have no idea if its two coils or two center tapped coils
06:51 AM polygon: 8(4) because one side of the bridge is the opposite of the other unless it is tristate...
06:53 AM polprog: https://puu.sh/zk066/9cc35f16ce.jpg
06:53 AM polygon: polprog: if it has 5 or 6 wires and 1 or 2 is the center then you can drive it with 4x n-fets and 4 diodes to v+
06:54 AM polprog: 5 wires
06:54 AM polprog: but one is NC. the blue one on the pic
06:54 AM polprog: i can take it apart again and take a closer look
06:54 AM polygon: polprog: https://en.wikibooks.org/wiki/Practical_Electronics/Stepper_Motors
06:55 AM polygon: you should not takeit apart
06:55 AM polygon: just use it
06:56 AM polygon: full bridge with mosfets does not need diodes mtw, mosfet has them builtin
06:57 AM polprog: brb
07:04 AM polprog: im worried about that blue wire
07:04 AM polprog: i have a dead scanner though, i may take a stepper from there
07:04 AM polprog: if this one doesnt work
07:21 AM polprog: okay, it moves, somewhat
07:24 AM polprog: blue coil is dead, rest of them make the shaft twitch a bit but it jumps back to its initial position after i release the signal (pushbutton)
07:25 AM polprog: https://youtu.be/YxH43FiS-_k
07:46 AM polprog: i think ive found another 6-wire stepper
08:07 AM polprog: very well.
08:07 AM polprog: this one works great!
08:07 AM polprog: thanks polygon rue_bed !
08:07 AM polprog: and that teac is dead. ill have to go get another one
08:18 AM rue_bed: er prolly
08:18 AM rue_bed: not
08:18 AM rue_bed: you can use a 6 wire in 4 wire mode
08:18 AM rue_bed: 99% that stepper is prolly fine
08:22 AM polprog: i did measure the resistances between the wires
08:23 AM polprog: the blue wire is not connected to anything
08:32 AM rue_bed: whaaaat
08:33 AM polprog: https://puu.sh/zk066/9cc35f16ce.jpg
08:34 AM rue_bed: maybe the stepper was ripped out by the wires?
08:34 AM polprog: it does have a dent in the cast metal chassis
08:34 AM polprog: could be that
08:35 AM rue_bed: oh its a 5 wire anyhow
08:35 AM rue_bed: its unipolar
08:36 AM rue_bed: it lookslike its got hacksaw marks in it
08:37 AM polprog: where exactly?
08:38 AM polprog: indeed its a ripped coil. i can clearly see it now
08:40 AM polprog: i see...
08:40 AM polprog: hmm ill try to unwind a single turn and solder the wire back to the distribution PCB
08:43 AM polprog: neat little device
08:46 AM polprog: https://puu.sh/zk2Vc/749fa27f7e.jpg
08:56 AM rue_: you may find that tiny peices of metal stick to the core of the motor, intermittently jamming it when you try to make it turn...
08:58 AM rue_: hey, you can convert that to a 4 wire stepper
08:58 AM rue_: (with bits of metal in it that randomly jam it)
08:59 AM rue_: there are 4 wires going to the (brown?) from coils, you want have them 2 splices
08:59 AM rue_: I cant remember what the pairs should be tho
08:59 AM polprog: it does jam but only when the shaft gets pushed towards the motor
09:00 AM polprog: im ok with this coil config though
09:03 AM polprog: i removed all those bits of metal
09:03 AM polprog: there werent any inside, the plastic stopped them
09:04 AM rue_: ok, 5 wire cant be used with either schematic you had
09:04 AM rue_: its unipolar
09:04 AM rue_: you drive it with 4 transistors
09:04 AM rue_: like ULN2003
09:05 AM rue_: or a ULN2803
09:05 AM polprog: i like uln2003
09:05 AM polprog: i need to get some more in DIP
09:05 AM rue_: the common goes to , probably 12V in your case
09:06 AM rue_: less it be said to have the phases the right way around, the step sequnce can be
09:06 AM rue_: 0001
09:06 AM rue_: 0010
09:06 AM rue_: 0100
09:06 AM rue_: 1000
09:06 AM rue_: BUT a better sequnce is
09:06 AM rue_: 0101
09:06 AM rue_: 0110
09:06 AM rue_: 1010
09:06 AM rue_: 1001
09:07 AM rue_: half stepping goes
09:07 AM rue_: 0001
09:07 AM rue_: 0011
09:07 AM rue_: er sorry, first line is error
09:07 AM rue_: start again
09:07 AM rue_: no I was right
09:07 AM rue_: you were? yea, go back to sleep
09:07 AM rue_: I was saying
09:07 AM rue_: 0001
09:07 AM rue_: 0011
09:07 AM rue_: 0010
09:07 AM rue_: 0110
09:08 AM rue_: 0100
09:08 AM rue_: 1100
09:08 AM rue_: 1001
09:08 AM polprog: i see
09:08 AM rue_: I blew it, before the 1001 should be 1000
09:08 AM polprog: yea, i see the pattern
09:09 AM polprog: i see why its called half stepping too
09:09 AM Neomex is now known as Painter
09:09 AM Painter is now known as Neomex
09:10 AM rue_: if the coils are not in the right order, it will just step right and left
09:19 AM rue_: that insulation can be trickey, did it take to solder?
09:19 AM polprog: same symptoms like before
09:19 AM polprog: it did solder
09:19 AM rue_: did it connect
09:20 AM rue_: you can have the solder just blob over it and not make a connection
09:20 AM polprog: yes, all coils have the same R to common
09:20 AM rue_: ah ok
09:20 AM rue_: so, put the common on 5V (not usb power)
09:20 AM rue_: and ground one of them, the shaft should lock
09:21 AM polprog: it moves, but doesnt step
09:21 AM rue_: correct, does it lock
09:21 AM polprog: what does lock mean?
09:21 AM rue_: can you spin it by hand with the common on 5V and one of them grounded
09:21 AM rue_: lock means it wont turn
09:22 AM polprog: it resits but i can
09:22 AM rue_: can you spin it by hand with the common on 5V and >one< of them grounded
09:22 AM rue_: yea, ok
09:22 AM rue_: so it should do that nomatter which one you ground
09:22 AM rue_: >one<
09:23 AM polprog: all 4 do this
09:23 AM rue_: yup, motor is 'fine' now
09:23 AM rue_: so, you need a driver, you said you have a uln2003?
09:23 AM polprog: i do
09:24 AM rue_: ok
09:24 AM rue_: do you know how to wire it up?
09:24 AM polprog: yes
09:25 AM rue_: https://i.stack.imgur.com/XUC5e.gif
09:25 AM rue_: but dont use the pwoer supply for the controller, for the motor
09:25 AM rue_: whent eh motor coils let go, they send a spike into the power supply
09:26 AM polprog: i know, wouldnt diodes help there?
09:26 AM rue_: so, if you have a 12V supply for the mtoor and a seperate 5V supply for the controller = good thing
09:26 AM rue_: the uln2003 has the diodes
09:26 AM rue_: they push the spikes into the power supply for you
09:26 AM polprog: yeah, i remember it has
09:26 AM polprog: aha
09:27 AM polprog: what if i used properly regulated 12->5V with filtering (ferrite cores, caps) ?
09:28 AM rue_: thats ok, just dont run the motor on the 5V then
09:28 AM rue_: https://coffemake.files.wordpress.com/2014/03/uln2003-control-stepper-motor.jpg
09:29 AM rue_: another way of doing it is to connect pin 9 to a LAMP (old school incadescent) to ground
09:29 AM rue_: or 5 to 10 ohm resistor
09:30 AM rue_: maybe 1 to 10
09:30 AM polprog: still, wouldnt enough filtering remove the spikes from the supply?
09:30 AM rue_: a huge cap would do a good job
09:30 AM polprog: or a set of caps?
09:31 AM rue_: meh
09:31 AM rue_: if the microcontroller keeps resetting, you know what the problem is
09:31 AM polprog: mm
09:32 AM rue_: avrs are REALLY tollerant of power line noise
09:32 AM rue_: pics reset from the slightest little bit of nosie
09:32 AM rue_: or usually just lock up
09:32 AM polprog: i have this quick and dirty 4-mos driver that works quite like the 2003. didnt manage to step this motor.
09:33 AM polprog: i have a different motor which does step on this
09:33 AM rue_: ditto motorola
09:33 AM rue_: lets see your code
09:33 AM polprog: there isnt any yet, there are 4 pushbuttons
09:33 AM rue_: your saying it dosn't even jitter back and forth?
09:33 AM rue_: na, too noisy
09:34 AM rue_: sometimes it works, other times it wont behave
09:34 AM polprog: it jitters a bit, but when i release the gate of the mosfet (pulled down) then it turns back
09:34 AM rue_: yea
09:34 AM rue_: its ok
09:34 AM rue_: it'll work fine on a microcontroller
09:35 AM polprog: ok, ill put together something with uln2003
09:35 AM rue_: using arduino or avr direct?
09:35 AM polprog: or those MOSes since i dont have a soic breakout
09:35 AM polprog: ofcourse direct avr.
09:35 AM polprog: ;)
09:36 AM rue_: isd the driver a SIP module?
09:36 AM polprog: what driver
09:36 AM * rue_ points at the ULN2003 on the PCB of the floppy drive the motor came from...
09:37 AM polprog: i didnt take it out from a floppy, got it "loose" like that
09:38 AM polprog: but now that you mentioned it, there must be a driver for that second mototr
09:38 AM polprog: motor*
09:39 AM rue_: off to work, bye!
09:39 AM rue_: (back in 9 hours)
09:39 AM polprog: bye
12:11 PM polprog: ive got 50mV amplitude noise on Vcc just from blinking a led, is that ok
12:13 PM polprog: the motor is on a separate supply
12:15 PM antto: current limitting resistor on the LED?
12:23 PM polygon: [16:02] <@rue_> ok, 5 wire cant be used with either schematic you had the fifth wire is the 2 coil's commen center tap:P so it can be run as a 4 wire
12:25 PM polygon: [16:24] <@rue_> so, if you have a 12V supply for the mtoor and a seperate 5V supply for the controller = good thing - separate ;)
12:26 PM polygon: polprog: soo now i fixed myself an aut darkening LCD welder filter
12:26 PM polygon: now i can pulse tig weld and see what im doing
12:26 PM polygon: *auto darkening
12:29 PM polygon: polprog: this is why they use capacitors :) try a 220uf cap ?
12:29 PM polygon: and a 100nf ceramic
12:39 PM * antto writes "100nF X7R" on polprog's forehead
12:39 PM * antto puts polprog's right leg on 5V
12:40 PM antto: behold, da human capacit0r
01:09 PM Jartza: ha
01:09 PM Jartza: https://imgur.com/A4V3Hop
01:10 PM Jartza: I love those breadboard attachments I printed
01:12 PM polprog: polygon: antto sorry i had scrolling off in my client, programming steppers
01:13 PM polprog: i have a 10n ceramic and a 10u electrolytic
01:15 PM polprog: ITS MOVING
01:15 PM Jartza: whee-o
01:30 PM polprog: shame the printer is down, id print a photo of somebody and make him wave his hand
01:32 PM McDonaldsWiFi: I need some good ideas how ti can turn an ATtiny into a valentine's day gift xD
01:32 PM polprog: https://twitter.com/polprogpl/status/962045151634849795
01:32 PM McDonaldsWiFi: maybe i can get it to say a sound bite
05:23 PM McDonaldsWiFi: Hey guys, its possible to use ArduinoISP as an extenral tool in atmel studio right?
05:23 PM McDonaldsWiFi: I'm trying to flash a ATtiny13a with my arduino and atnel studio
05:35 PM polprog: im pretty proud of this stepper running
05:36 PM polprog: in one day i repaired it, and made a driver board from scratch
05:36 PM polprog: im surprised i had the drive to do it..
07:06 PM rue_: polprog, the good motor of the repaired one?
08:07 PM [1]MrMobius is now known as MrMobius
09:21 PM nuxil: rue_, https://i.gyazo.com/f11b8678614bbb5a524ab2517b4483b2.jpg i got my bannana sockets :) just missing a couple of green ones, but its ready for use :D
09:22 PM nuxil: build 98% done :p
11:42 PM day__ is now known as day