Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Junebug VR1 and VR2 strangeness

Status
Not open for further replies.
For Junebug users, here's the final silly little demo program. It flashes LED 1 with delay set by VR1 and flashes LED 2 with delay set by VR2.

When both pots are full CCW (counter-clockwise) the LEDs will appear to both be on full time. They are both blinking still, but very quickly.

Code:
	list	p=18F1320
	include	<p18F1320.inc>
	CONFIG	OSC=INTIO2,WDT=OFF,MCLRE=ON,LVP=OFF

	cblock	0x00
	d1,d2,d3,speed,speed2,temp
	endc

	org	0x0000
init	bsf	OSCCON,IRCF2	;set to 8MHz clock
	bsf	OSCCON,IRCF1
	bsf	OSCCON,IRCF0
	movlw	b'00001010'	;set PORTA to all outs except RA1 and RA3
	movwf	TRISA
	clrf	TRISB
	clrf	LATA		;and zero them
	clrf	LATB

	movlw	b'00000100'	;init a/d
	movwf	ADCON0
	movlw	b'01110101'
	movwf	ADCON1
	movlw	b'00011101'
	movwf	ADCON2

main	call	analog		;read the a/d pins
	bsf	LATA,0		;blink LED 1
	bcf	LATA,6
	bsf	TRISA,7
	call	delay		;with delay length determined by VR1
	bcf	LATA,0
	bcf	LATA,6
	bcf	TRISA,7
	call	delay
	bcf	LATA,0		;blink LED2
	bsf	LATA,6
	bsf	TRISA,7
	call	delay2		;with delay length determined by VR2
	bcf	LATA,0
	bcf	LATA,6
	bcf	TRISA,7
	call	delay2
	goto	main

analog	movlw	b'00000101'	;enable A/D, AN1
	movwf	ADCON0
	bsf	ADCON0,GO	;go do a/d conversion
adloop	btfsc	ADCON0,DONE
	goto	adloop
	movff	ADRESH,speed	;get the value in speed
	incf	speed,F		;prevent loop value from going to 0
	movlw	b'00001101'	;enable A/D, AN3
	movwf	ADCON0
	bsf	ADCON0,GO	;go do a/d conversion
adloop2	btfsc	ADCON0,DONE
	goto	adloop2
	movff	ADRESH,speed2	;get the value in speed2
	incf	speed2,F	;prevent loop value from going to 0
	return

delay	movlw	0xff
	movwf	d1
	movff	speed,d2
delay_0	decfsz	d1,F
	goto	$+6
	decfsz	d2,F
	goto	delay_0
	return

delay2	movlw	0xff
	movwf	d1
	movff	speed2,d2
delay_3	decfsz	d1,F
	goto	$+6
	decfsz	d2,F
	goto	delay_3
	return

	END

Now on to bigger and better things! :D
 
Except it crashes when you try to use some parts of it. Some error trapping would be nice. Anyway, the part I wanted does work.

yeah it's kinda annoying, i'm aware of some of those warning/error message. Seems to appear on some machine, not on others.

2 thing i would suggest you to try
1) download the installation pack www.mister-e.org/Download/setup.zip
2) if it's still return an error, download and install Microsoft ActiveX Control Pad https://msdn2.microsoft.com/en-us/library/ms968493.aspx

this should fix the problem forever. Sorry for the problems. I'm moving it on another language when i have some spare time.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top