Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Case statment problem.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
DJD XTREEM

Bascom Member



Joined: 24 Jun 2004
Posts: 190
Location: 127.0.0.1

netherlands.gif
PostPosted: Tue Jul 20, 2004 9:15 pm    Post subject: Case statment problem. Reply with quote

I'm trying to get an interface working:
At the end it have to work on RC5 remote to controll 4 relays.

Now i haveing trouble to control the output ports.
Code:
$lib "mcsbyte.lbx"
Config Portb = Output
Dim Bcommand As Byte

Do

Input "Commando: (00-99)" , Bcommand
Select Case Bcommand
  Case 20 : Print "1 on"
  Case 21 : Portb.1 = 0
  Case 22 : Portb.2 = 1
  Case 23 : Portb.2 = 0
  Case 24 : Portb.3 = 1
  Case 25 : Portb.3 = 0
  Case 26 : Portb.4 = 1
  Case 27 : Portb.4 = 0
  Case Else : Print "not found"
End Select
Loop

End

As can seen at Case 20.. it works propperly to give out the text: 1 on..
Only if i try to controlinduvidual a port.. It won't work. Maybe somebody can tell me why i can't control the ports?

_________________
Bascom AVR 1.11.8.8 full version
STK500 Programmer
ISP Programmer
Back to top
View user's profile Visit poster's website MSN Messenger
philm

Bascom Member



Joined: 14 Jul 2004
Posts: 138
Location: Australia

australia.gif
PostPosted: Wed Jul 21, 2004 3:02 am    Post subject: Reply with quote

try
Code:

Select Case Bcommand
  Case 20 : Print "1 on"
  Case 21 : Reset Portb.1
  Case 22 : Set Portb.2
  Case 23 : Reset Portb.2
  Case 24 : Set Portb.3
  Case 25 : Reset Portb.3
  Case 26 : Set Portb.4
  Case 27 : Reset Portb.4
  Case Else : Print "not found"
End Select
 
Back to top
View user's profile
DJD XTREEM

Bascom Member



Joined: 24 Jun 2004
Posts: 190
Location: 127.0.0.1

netherlands.gif
PostPosted: Wed Jul 21, 2004 8:23 am    Post subject: Reply with quote

Doesn't work either.. The case statement works fine.. Because if i hit 33 it gives me the NOT FOUND error.. but the controll of the port doesn't work yet..
_________________
Bascom AVR 1.11.8.8 full version
STK500 Programmer
ISP Programmer
Back to top
View user's profile Visit poster's website MSN Messenger
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5319
Location: Holland

blank.gif
PostPosted: Sat Jul 24, 2004 2:48 pm    Post subject: Reply with quote

make sure that all bitws can be set :
config portb=output
dim j as byte
do
portb=0
for j=0 to 7
portb.j = 1
waitms 1000
next
loop

this will make all pins 1. with some leds it is easy to test

_________________
Mark
Back to top
View user's profile Visit poster's website
DJD XTREEM

Bascom Member



Joined: 24 Jun 2004
Posts: 190
Location: 127.0.0.1

netherlands.gif
PostPosted: Sat Aug 07, 2004 5:55 pm    Post subject: Reply with quote

Got it work now..
The problem was that the simulater has a bug so the port doesn't work good at all..

I loaded this code in my AVR and that worked well..
Code:
Config Portb = Output
Config Rc5 = Pind.4
Enable Interrupts

Dim Baddress As Byte
Dim Bcommand As Integer


Portb = 255                                                 'had to do this with the AVR Development board
Do
Getrc5(baddress , Bcommand)                                 'recieving data from ir eye


'-----------------------------------------------------
'|Starting of build-in code analyser for RC5
'|Baddress and Bcommand can be readout with terminal programm
If Baddress < 255 Then                                      '< otherwise terminal output will be continue 255 255 when no data send
Print Baddress ; " " ; Bcommand                             'gives readout on terminal
End If



If Baddress = 21 Then                                       'checks for valid address
Select Case Bcommand                                        'set or resets the output pins when there is a command

  Case 128 : Set Portb.0
  Case 144 : Reset Portb.0
  Case 129 : Set Portb.1
  Case 145 : Reset Portb.1
  Case 130 : Set Portb.2
  Case 146 : Reset Portb.2
  Case 131 : Set Portb.3
  Case 147 : Reset Portb.3



End Select
End If
Loop

The code is made for a 90s2313 and recieve rc5 and will controll 4 relays.
A scheme will posted later when i finished that part. Wink

_________________
Bascom AVR 1.11.8.8 full version
STK500 Programmer
ISP Programmer
Back to top
View user's profile Visit poster's website MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum