Temo, PWM, and portc

craig008

New Member
hey all i have a PWMout and temp connected to the output of a 28X and now due to LCD connection i need to connect an LED to pin7 on portc. now the problem is that the portc works fine in one programme but when it is put into the final programme it does not work, is it due to the temp and pwmout on the same port creating a problem
________
Nh80
 
Last edited:

hippy

Technical Support
Staff member
Could be. You'd have to tell us more about what you've got connected to what and how you are using Port C to give a definite answer.
 

craig008

New Member
to input 0 i have a ds18b20 to readtemp12 - pretty simple
to pwmout1 i have a transistor driving a set of LEDs
to the portc7 i have the last pin of a uln2803
this is the code that i am testing at the mo, if it is of any help.

Code:
start:
	portc = %10000000		'using portc pin as pin 7 will be used for serial line
	peek $c1,b9
	peek $c2,b10
	if b9 = 0 then gosub B_9
	if b10 = 0 then gosub B_10

main:
	let b4 = 0
	let b3 = 0
	readtemp12 0,w6
	let w6 = w6*10/16
	let b1 = w6/10
	let b2 = w6//16
	sertxd ("Temp: ",#b1,44,#b2,13,10)
	
temp:
	if pin5 = 1 and pin6 = 1 then temp_select
	pause 500

	if b1 < b9 then gosub P_1
	if b1 > b9 and b1 < b10 then gosub P_2
	if b1 > b10 then gosub panic
	if b0 = 255 then down
	
up:
	pwmout 1, 63, b0
	let b3 = b3 + 1
	if b3 = 32 then LED_1
	if b0 = 255 then main
	let b0 = b0 + 1
	goto up
	
down:

	pwmout 1, 63, b0
	let b3 = b3 + 1
	if b0 = 0 then main
	if b3 = 32 then LED_2
	let b0 = b0 - 1

	goto down
	

LED_1:
	let b4 = b4 + 1	
	let pins = %00000001
	let b3 = 0
	if b4 = 1 then up
	let pins = %00000011
	let b3 = 0
	if b4 = 2 then up
	let pins = %00000111 
	let b3 = 0
	if b4 = 3 then up
	let pins = %00001111
	let b3 = 0
	if b4 = 4 then up
	let pins = %00011111
	let b3 = 0
	if b4 = 5 then up
	let pins = %00111111
	let b3 = 0
	if b4 = 6 then up
	let pins = %01111111
	let b3 = 0
	if b4 = 7 then up
	let pinsc = %10000000		'using portc pin as pin 7 will be used for serial line
	let b3 = 0
	goto up
	
LED_2:
	let b4 = b4 + 1	
	let pins = %00000000
	let b3 = 0
	if b4 = 8 then down
	let pins = %00000001
	let b3 = 0
	if b4 = 7 then down
	let pins = %00000011 
	let b3 = 0
	if b4 = 6 then down
	let pins = %00000111
	let b3 = 0
	if b4 = 5 then down
	let pins = %00001111
	let b3 = 0
	if b4 = 4 then down
	let pins = %00011111
	let b3 = 0
	if b4 = 3 then down
	let pins = %00111111
	let b3 = 0
	if b4 = 2 then down
	let pinsc = %00000000		'using portc pin as pin 7 will be used for serial line
	goto down

P_1:
	pause 1000
	return
	
P_2:
	pause 150
	return
	
panic:
	let pins = %11111111
	pwmout 1, 63, 255
	readtemp12 0,w6
	let w6 = w6*10/16
	let b1 = w6/10
	let b2 = w6//16
	sertxd ("Panic Stations, its getting a little hot: ",#b1,44,#b2,13,10)
	let pins = %00000000
	pwmout 1,62, 0
	pause 500
	if b1 > 35 then panic
	return

temp_select:
	pause 500
	sertxd ("Normal Op Temp")
	if pin5 = 1 then gosub B_9up
	if pin6 = 1 then gosub B_9down
	if pin5 = 1 and pin5 = 1 then temp_select1
	goto temp_select
	
	
temp_select1:
	pause 500
	sertxd ("Upper Op Temp")
	if pin5 = 1 then gosub B_10up
	if pin6 = 1 then gosub B_10down
	if pin5 = 0 and pin6 = 0 then temp_select1
	poke $c0,b9
	poke $c1,b10

	goto temp
	
B_9up:
	let b9 = b9 + 1
	return
	
B_9down:
	let b9 = b9 - 1
	return
	
B_10up:
	let b10 = b10 + 1
	return
	
B_10down:
	let b10 = b10 - 1
	return
	
B_9:
	let b9 = 30
	poke $c1,b9
	return
	
B_10:
	let b10 = 35
	poke $c2,b10
	return
the reason for using the portc for the final LED, is the sertxd will be replaced by serout7 so that the baud rate is correct for the lcd when it arrives.

i was thinking that if there is a small amount of power outage it could be boosted with a low power transistor

hopefully there arent too many errors in this code, doesnt seem to be yet
________
MODEL C TEN
 
Last edited:
Top