Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:45 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : picomite PWM

Author Message
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 01:21am 28 Jan 2024
Copy link to clipboard 
Print this post

Need some help with the following program for a train controller using HC-06 bluetooth module.

Bluetooth working OK,the problem is the PWM control not accepting the setpin.

'Bluetooth Train control for the picomite and HC-06 bluetooth module
'28/01/2024
'Bill Brown
Option colourcode on
Option autorun on
Option DEFAULT NONE
Dim  aa$
Dim integer c(4),x
dim integer FWDSelect
dim integer REVSelect
dim integer counter1

SetPin GP22, Dout

setpin gp5, dout
setpin gp6, dout
setpin gp7, dout
setpin gp8, dout
setpin gp9, dout
SetPin GP12, pwm6A
SetPin GP10, pwm5A

counter1 = 0
'--------------------------------------------
SetPin GP0, Gp1, com1
Open "com1:9600,256,intmenu, 2" As  #1
Do

Loop
'********* Bluetooth selection from HC-06 **********************
Sub intmenu
aa$=(Input$(2,#1))
x = Val(aa$)
Print "x= "x,
Pause 100
Select Case x
Case 11    'Light ON
  print "1",
 ' pin GP5 = 1
Case 22   'Light OFF
  print "2",
 ' pin GP5 = 0
Case 33    'Smoke ON
  print "3",
  pin GP6 = 1
  pin GP7 = 0
Case 44    'Smoke OFF
  print "4",
  pin GP6 = 0
  pin GP7 = 0
Case 55       'Forward
  print "5",
  FWDSelect = 1
  RevSelect = 0
Case 66      'Reverse
  print "6",
  FWDSelect = 0
  RevSelect = 1
Case 77      'Train Stop
  PWM 5 OFF
  PWM 6, OFF
Case 88      ' increase Train Speed
  If FWDSelect = 1 then
     counter1 = counter1 + 10
    if counter1 > 100 then
        counter1 = 100
    endif
  endif
  print "8",  
  print Counter1
  PWM 6,1000,,counter1
  PWM 5, OFF
Case 99        'Decrease Train Speed  
  print "9",  

  If REVSelect = 1 then
    counter1 = counter1 - 10
    if counter1 < 0 then
     counter1 = 0
   endif
  endif
  print counter1
 PWM 5,1000,,counter1
 PWM 6, OFF
end select
End Sub

*************************************************
Maximite Control Centre
Build date: 2023/10/13
  Data server on port 50900 started
Control server on port 50899 started
started
D:\mmfiles\TrainControl.bas
Uploading using:  'target port\COM11: s\
Upload started
Connected to COM11 at  
NEW
>
>
AUTOSAVE

Upload completed 1
Saved 1560 bytes
>
Time taken: 3235mS
RUN
x=  55 5       x=  88  8        10
[71] PWM 6,1000,,counter1
Error : Pin not set for PWM
>



Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 01:57am 28 Jan 2024
Copy link to clipboard 
Print this post

Remove the second comma
PWM 6,1000,counter1

It thinks you have 6B configured.

Same for 5B later in the code.

Jim
VK7JH
MMedit   MMBasic Help
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 02:49am 28 Jan 2024
Copy link to clipboard 
Print this post

Thanks  Jim

That did the trick.  Working OK now.

Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024