Hallo,
Hopelijk staat dit onder de correcte topic, indien niet mijn excuses hiervoor. Ik ben momenteel bezig aan een project in bedrij waar we een droptestunit moeten bouwen. Mijn taak is de elektronische en IT kant van de zaak. Nu wil ik stappenmotoren aan sturen via de PC. Ik weet dat dit al veel voorgekomen is, onderwerpen over stappenmotoren maar ik kan niet vinden wat ik zoek.
Ik heb ook al veel gelezen en bijgeleerd over stappenmotor zodat nu praktische ontwerp problemen voorkomen.
Mijn idee:
Via labview wordt over RS232 naar een PIC16F84 (met UART?) gegevens (commando's voor de stappenmotor) gestuurd. Hiertussen plaats ik een MAX232 om de spanningsverschillen om te zetten. Eens in de PIC, die ik zal programmeren in assembler, laat ik lijnen vertrekken naar een UCN5804 die vermogen pompt in het signaal om uiteindelijk te belanden bij de stappenmotor.
(indien hier verbeteringen of suggesties zijn, laat u hart spreken)
Nu zou ik moeten 6 stappenmotoren moeten aansturen,
een idee van een collega, plaats een multiplexer tussen de PIC en de vermogensbrug. Nu beginnen er wat problemen voor mij. De max pulsentreinfrequetie (per motor) zou 10kHz zijn. Dus als ik wil multiplexen, moet ik weten wat de dutycyle is om te kijken of er nog 5 andere motoren tussen gepropt kunnen worden (of is mijn redenering al naar de knoppen?). Maar nu weet ik niet goed hoe ik die dutycycle moet bepalen per motor? Doe ik dit via, je weet je spanning, je weet hoeveel stroom ie trekt (bij het opstarten, verplaatsing van massa = meer stroom dacht ik) en op basis hiervan kan ik een pulse width berekenen? En dan kijk ik of er nog 'plaats' genoeg is tot de volgende cyclus voor 5 andere pulsen?
Of sla ik het totaal verkeerd?
hartelijk dank alvast voor alle hulp,
Roland van Leusden
It's the rule that you live by and die for It's the one thing you can't deny Even though you don't know what the price is. It is justified.
Je kan met 1 PIC makkelijk meerdere UCN5804 aansturen:
http://www.baronerosso.net/mod-subjects-viewpage-pageid-112.html
Om 6 stappenmotoren te sturen zou ik 6x4 uitgangen nodig hebben. Zo'n PIC16F84 is handig en goedkoop en daarom dacht ik daar aan.
Nog een ander, idee die ik opgevangen heb:
http://www.latticesemi.com/products/cpld/ispMACH4A5/index.cfm
een decoder met 3state buffer uitgangen, zou principieel ook moeten werken?
Een F84 heeft toch geen uart?
En een F84 is erg duur. Ik zou een F628a nemen. Deze is pincompatibel en heeft wel een UART.
ledfreak
Moderator green laser forum http://www.greenlasers.co.uk/cgi-bin/yabb/YaBB.cgi
Op 5 augustus 2005 16:12:30 schreef DIY:
Een F84 heeft toch geen uart?
En een F84 is erg duur. Ik zou een F628a nemen. Deze is pincompatibel en heeft wel een UART.
duur ? heb nog nooit voor een pic controller betaald gewoon sampelen
Roland van Leusden
It's the rule that you live by and die for It's the one thing you can't deny Even though you don't know what the price is. It is justified.
Om 6 stappenmotoren te sturen zou ik 6x4 uitgangen nodig hebben. Zo'n PIC16F84 is handig en goedkoop en daarom dacht ik daar aan.
Lees eerst het datasheet van de UCN5804 maar, je hebt maar 2 I/O lijnen nodig namelijk voor STEP en DIRECTION. Dit had je ook kunnen vinden in de link die ik eerder gepost heb.
Ben Devos
Visit Me: http://www.basicfox.com
Ik heb ook een klein vraagje...
Dit stond in een mail:
Parallel, 5A , koppel 4 Nm
Serieel , 2.5 A , koppel 4 Nm
Unipolair , 3.5 A , koppel 2.82 Nm
maar wie weet wat parallel aansturen is (ik veronderstel bipolair)
en serieel ken ik al totaal niet...
Wie kan mij meer uitleg geven 
(kheb zo'n motor gekocht)
GRTZ
WTFox
@Roland,
inderdaad je hebt gelijk aangaande die datasheet,mijn excuses. Maar die link, vriendelijk dat je dat post, maar mijn Italiaans (?) is toch niet van dat niveau om die pagina te begrijpen.
elmowww
PA0EJE - www.eje-electronics.nl - e.jongerius[aapje]eje-electronics.nl - EJE Electronics - Elektronica/firmware ontwikkeling
Op 5 augustus 2005 23:56:59 schreef TheNighthawk:
@Roland,
inderdaad je hebt gelijk aangaande die datasheet,mijn excuses. Maar die link, vriendelijk dat je dat post, maar mijn Italiaans (?) is toch niet van dat niveau om die pagina te begrijpen.
Neem een 16F870 of een 877. Dan heb je al meer dan zat lijnen.
In een eenmalig te bouwen project is het naar mijns inziens handiger om een hele dikke controller te kopen, en overige hardware uit te sparen.
Nu hoef je geen tijd te verspillen aan de multiplexing, poorten zat voor 15 ipv 6 euro.
Ik neem aan dat jij ook enkele tientjes per uur kost, en dat je in 15 minuten nog niet alles van de mux klaar hebt 
Roland van Leusden
It's the rule that you live by and die for It's the one thing you can't deny Even though you don't know what the price is. It is justified.
Op 5 augustus 2005 23:56:59 schreef TheNighthawk:
@Roland,
inderdaad je hebt gelijk aangaande die datasheet,mijn excuses. Maar die link, vriendelijk dat je dat post, maar mijn Italiaans (?) is toch niet van dat niveau om die pagina te begrijpen.
Mijn italiaans is ook niet best hoor, het ging meer om het shema wat daar stond. De PIC 16F84 heeft op zich genoeg i/o alleen ben ik bang dat de 1Kb flash te weinig zal zijn.
Zelf zou ik idd een grotere PIC nemen en ea in PICBASIC programeren, dan ben je namelijk in een paar uur klaar.
Het PICBASIC voorbeeld hieronder kun je zonder al teveel wijzigingen zo gebruiken.
http://www.picbasic.co.uk/forum/showthread.php?t=101
It looks like this code could be valuable to quite a few users, so here you go. I originally developed this system about 15 years ago using basic stamps, but over the years it has had modifications as the hardware has changed and moved on to PICS. I work at a National Laboratory and wanted to save the Govt some money, so instead of buying commercial stepper systems I developed my own. The system began as a single stepper that needed to be moved remotely via RS-232. It eventually grew to a requirement to drive about 10 separate (UNIPOLAR) motors on a laser table to operate attenuators and X-Y linear stages. The theory behind the system is each stepper has its own PIC. All PICS are sitting on a single RS-232 bus in parallel. Each PIC "listens" for its name to be called and reponds only when called. This avoids any chance of a communication collision. The code will work for any number of PICS placed on the single RS-232 bus until you have loaded down the impedance of the bus so far that you cannot sustain communications. I have never needed more than 10 steppers on a single bus, but if you work out the math you could calculate the maximum. This code doesn't use the USART pin, so I have a 20K resistor on each PIC for the SerIn pin.
Hardware: Each stepper motor is on an apparatus that has a limit switch for the "home" position. If a power failure occurs or if requested to reset via the RS-232, it will drive the stage home and reset its counter to zero position.
I have found that the system is so reliable that I do not need to have additional encoders to sense the position. If you ensure that your motor is not overloaded and drive it with the proper current, it will never slip poles and the software count of current position will be quite accurate.Software: The code follows. This same software is loaded into each PIC on the system, but the name and travel limit settings are changed for each . I have another version of the code that allows one to input a new name and travel limit via the RS-232 into NVRAM, but I felt it was overly complicated for sharing.
Command protocol: A terminal program (terraterm or equivalent) would send the name of the stepper followed by a space and then the new postion command or a special control code.
Example 1. Send the stepper to reset position:
ATTENB 65535Example 2. Move the stepper to position 415:
ATTENB 415Example 3. Ask the stepper its current position:
ATTENB 65534
The PIC would then respond with "AttenB @ 415"Heres the PIC code:
'************************************************* *************** '* Name : StepNetwork.pbp Target=PIC16F84 OR F628 * '* Author : John C. Hansknecht * '* Notice : Copyright (c) 2004 * '* : All Rights Reserved * '* Date : 10/14/04 * '* Version : 1.0 * '* Notes : ' Universal code for all stepper controllers in a serial network. ' Only the name and travel limit ' are changed for the specific device. '************************************************* *************** '_______ Declarations __________________________________________________ ___ PAUSE 500 include "modedefs.bas" '@ device INTRC_OSC_NOCLKOUT 'default to internal oscillator '@ device WDT_ON 'watchdog timer on '@ device PWRT_ON 'power on timer on '@ device MCLR_OFF ' master clear option off '@ device BOD_OFF ' brown out detect '@ device LVP_OFF ' low voltage programming off '@ device PROTECT_OFF ' program code protect off Steps var word I var word newval var word oldval var word resetbit var byte b0 var byte pins var portb endstop var portb.4 define osc 4 '_______ Initializations __________________________________________________ TRISB = %10110000 pins = 0 ' Initialize output all output transistor OFF. oldval = 0 input portb.5 'make serout a high impedence so all others can talk '________Main program___________________________________________ ___________ pause 500 reset: resetbit = 0 if endstop = 0 then del1 'take motor CCW to limit switch on pwrup. oldval = 0 Cmd:resetbit = 1 serin 7,N2400,["ATTENB"],#newval ' Get orders from terminal. if newval = 65534 then report 'just report current position if newval = 65535 then reset 'send motor to limit switch if newval > 600 then Cmd ' My own software motion limit if newval < oldval then delstep if newval = oldval then Cmd ' else we will drop into addstep (inferred goto) addstep: steps = newval - oldval for I = 1 to Steps ' Number of steps. for b0 = 0 to 7 'full step mode used here. LOOKUP b0,[9,1,3,2,6,4,12,8],PINS 'forward drive sequence pause 1 next b0 NEXT I oldval = newval 'make oldval reflect the current position. goto Cmd delstep: steps = oldval - newval FOR I = 1 TO steps del1: for b0 = 0 to 7 'enters sub here if resetting motor LOOKUP b0,[12,4,6,2,3,1,9,8],PINS pause 1 next b0 if resetbit = 0 then reset 'exit this sub if resetting motor NEXT I oldval = newval goto Cmd report: serout 5, N2400, ["ATTENB @ ",#oldval,13] input portb.5 'make serout pin an input so others can talk goto Cmd '___ End of program