Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 69
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
No birthdays today

Next birthdays
11/29 Sonic (58)
11/29 kamelryttarn (46)
11/30 arnsfelt (45)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

DRSSTC Interrupter, PIC based

 1 2 3 
Move Thread LAN_403
JimG
Tue May 30 2006, 12:46PM
JimG Registered Member #52 Joined: Thu Feb 09 2006, 04:22AM
Location: Austin TX
Posts: 57
Anders M. wrote ...

JimG, what are the limitations of your controller (min. on-time, how big steps the on-time can be adjusted in, max. on-time, max. BPS)?

On time is 20-230us in increments of 10us. BPS is 10 to 200 in increments of 5.

Looking at the code it looks like this is one of the source files where I was experimenting with a random variance to the on time, so if you use this code your coil may not sound normal.

I found a rotary encoder with a push-button and a 20 Mhz resonator so I may rewrite the code to make it easier for people to poke around with it and try out a few different pic models. Right now the ones I have on hand are 16f84, 16F819, 16f628, and a 16F88.

I don't have the time or resources that Dan has to put features into it, but I'm sure I can make it a little more hacker friendly than the one that I have now.
Back to top
EDY19
Thu Jun 01 2006, 11:31AM
EDY19 Registered Member #105 Joined: Thu Feb 09 2006, 08:54PM
Location:
Posts: 408
I'd really like to get into this PIC stuff, there is so much that one can do with a programmable chip. Does anyone have any good beginner book suggestions or websites that would be a place to start? I've already gone through one datasheet for the 16F628.
Back to top
JimG
Fri Jun 02 2006, 02:26AM
JimG Registered Member #52 Joined: Thu Feb 09 2006, 04:22AM
Location: Austin TX
Posts: 57
You may want to start up a new thread if you want to get any meaningful advice on how to use pic microcontrollers. A lot will depend on how comfortable you are with assembly language in general. You could always start with piclist or Microchip's forums. I can't suggest any books since I just picked most of what I knew by looking at the instructions and reading about other people's solutions to problems.
Back to top
EDY19
Fri Jun 02 2006, 02:38AM
EDY19 Registered Member #105 Joined: Thu Feb 09 2006, 08:54PM
Location:
Posts: 408
I wasn't looking to start a new topic on PICs, I just wanted to know if there were any good books on them that I could start with. I'll just do some searches for the assembly language and see what turns up.
Back to top
...
Fri Jun 02 2006, 03:30AM
... Registered Member #56 Joined: Thu Feb 09 2006, 05:02AM
Location: Southern Califorina, USA
Posts: 2445
I would personally start with something other than assembly.

If you want really simple you could use mikrobasic (it has a pretty good manual and a great forum)
If you want a 'real' programming language I would go with mplab from microchip. I haven't used it but this seems like a good place to start.
If you don't mind leaving the main stream, you might try mikroC as it has a ton of libraries that the student (and probably full) version of mplab...

good luck!
Back to top
Wolfram
Fri Jun 02 2006, 04:49AM
Wolfram Registered Member #33 Joined: Sat Feb 04 2006, 01:31PM
Location: Norway
Posts: 971
Why not start in assembly? PIC assembly is not very hard, and once you understand the basics you can learn all you need in a couple of hours.

This is where I learned PIC assembler: Link2 . Beware, it has got a couple of errors, like this one:

DECFSZ COUNT,1

This instruction says ‘Decrement the register (in this case COUNT) by the number that follows the comma. If we reach zero, jump two places forward.’ A lot of words, for a single instruction. Let us see it in action first, before we put it into our program.


This instruction doesn't decrement the register value by the number that follows the comma, the register is always decremented by 1. The number after the comma tells the PIC where to put the result of the instruction. 1= to the register, 0= to W. I prefer to use F and W instead, looks much nicer. I.e. decfsz COUNT,F
Back to top
EDY19
Fri Jun 02 2006, 08:09PM
EDY19 Registered Member #105 Joined: Thu Feb 09 2006, 08:54PM
Location:
Posts: 408
The two links you posted aren't working- is that my computer or the links?
Back to top
Wolfram
Fri Jun 02 2006, 08:38PM
Wolfram Registered Member #33 Joined: Sat Feb 04 2006, 01:31PM
Location: Norway
Posts: 971
Fixed. The period at the end of the sentence got mixed into the URL.
Back to top
JimG
Mon Jun 05 2006, 06:49AM
JimG Registered Member #52 Joined: Thu Feb 09 2006, 04:22AM
Location: Austin TX
Posts: 57
Steve Conner wrote ...

To do this, I just take the state of the lines "now" as the two LSBs, and the previous state as the next two higher order bits, to form a 4-bit state vector. Then I do a computed goto on that 4-bit number. So depending on both the current and the previous state, the program jumps to a routine that adds one to the encoder position register, or a routine that subtracts one, or a routine that does nothing. For convenience, I also have the first two of those routines set a flag to tell the main program that someone moved the control knob.


I know this is pretty minor, but it looks like this can be done with only 3 bits. Since there are only 8 valid states I figured there should be a way to represent the table using only 3 bits. By dropping one bit from the previous position you can still have a unique value for all 8 states. This would allow for the table size to be cut in half without the need for empty entries.
Back to top
Steve Conner
Mon Jun 05 2006, 09:23AM
Steve Conner Registered Member #30 Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
Yea, but which bit do you drop under what circumstances? You'd need tests to detect the invalid states, and the whole point of the goto table is to replace all that logic with one easy to understand thing. The encoder lines are connected to PORTB,0 and PORTB,1 and the push button is connected to PORTB,2. PORTB Interrupt-On-Change is turned on, and the main ISR jumps to the following code on a PORTB change.

; Encoder handling routine
; Generates a 4-bit state vector composed of current state of quadrature outputs and previous state
encode	bcf	INTCON,RBIF
	rlf	ectemp,F
	rlf	ectemp,W
	andlw	B'1100'
	movwf	ectemp
	swapf	PORTB,W
	andlw	B'11'
	iorwf	ectemp,F	; ectemp(3:0) now contains At-1, Bt-1, At, Bt

; Increments, decrements, or leaves the counter alone
	movlw	HIGH($)
	movwf	PCLATH
	movf	ectemp,W
	addwf	PCL,F		; computed goto

; Computed goto table
	goto	encnop		; 0 do nothing
	goto	encdec		; 1 anticlockwise
	goto	encinc		; 2 clockwise
	goto	encnop		; 3 do nothing
	goto	encinc		; 4 clockwise
	goto	encnop		; 5 nothing
	goto	encnop		; 6 nothing
	goto	encdec		; 7 anticlockwise
	goto	encdec		; 8 anticlockwise
	goto	encnop		; 9 nothing
	goto	encnop		; 10 nothing
	goto	encinc		; 11 cw
	goto	encnop		; 12 nowt
	goto	encinc		; 13 cw
	goto	encdec		; 14 ccw
	goto	encnop		; 15 nowt

; this code has been changed because someone wired the encoder
; backwards on the production unit, who could that have been?
encinc	decf	ecval,F		; _DE_crement the encoder position
	bsf	ecmoved,0	; set the "Encoder Was Moved" flag
	goto	encnop

encdec	incf	ecval,F		; _IN_crement it
	bsf	ecmoved,0	; clear the Encoder Was Moved flag

encnop	clrf	ecbtn
	btfss	PORTB,2		; check if the button was pressed?
	bsf	ecbtn,0		; if so, set button pressed flag

	btfsc	subflg,0
	return
Back to top
 1 2 3 

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.