Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:56 24 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 : maxi pwm prog help needed

Author Message
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 09:38pm 05 Sep 2011
Copy link to clipboard 
Print this post

i am try ing to get this program to reed three seperat pins have tried as much as i know how but cant get the voltages to seperate ...you will need gerards hex to run it he has posted it before or you may have it around ...thanks to all who can assist ...or tell me where i am going wrong

5 'initialise I/O pins
10 PIN1 = voltpin,1 'set analog voltage input pin (can be 1 - 10)
15 PIN2 = voltpin,1 'set analog voltage input pin (can be 1 - 10)
20 PIN3 = voltpin,1 'set analog voltage input pin (can be 1 - 10)
30 pwmpin = 8 'set the pwm output pin (can be 7 - 10)
40 freq = 120 'set initial frequency to 100Hz (can be 1 - 5000)
50 duty = 50 'set initial duty cycle to 50% (can be 0 - 100 in increments of 1)
60 offset = 0 'use to adjust for any offset in analog input
70 coefficient = 20 'use to scale the analog input
80 tick_avg = 100 'number of analog voltage samples to average each second
85 tick_flag = 0
90 tick_cnt = 0
95 DIM tick_array(tick_avg)
100 SETPIN= voltpin,1 'configure pin for analog input
102 REM SETPIN(2) voltpin,1 'configure pin for analog input
104 REM SETPIN(3) voltpin,1 'configure pin for analog input
115 SETPIN pwmpin,10,freq,duty 'initiate PWM output
120 SETTICK CINT(1000/tick_avg),1100 'set tick interrupt for tick_avg per second
150 duty_str$ = "Enter duty cycle (0 - 100 for 0% - 100%), 'F' to change frequency or 'Q' to quit"
160 freq_str$ = "Enter frequency (1 - 5000 for 1 - 5kHz), 'D' to change duty cycle or 'Q' to quit"
200 CLS
210 volt = offset + (PIN(voltpin) * coefficient)
220 state = 1
230 LOCATE 0,24 : ? "MAIN BUSS A v+ =";
232 LOCATE 108,24 : ? FORMAT$(volt,"% .3fV ");
236 LOCATE 0,156 : ? "9 VOLT RAIL V+ =";
240 LOCATE 108,156 : ? FORMAT$(volt,"% .3fV ");
244 LOCATE 0,196 : ? "5 VOLT RAIL V+ =";
247 LOCATE 108,196 : ? FORMAT$(volt,"% .3fV ");
252 LOCATE 0,60 : ? "Running frequency =";
255 LOCATE 114,60 : ? freq; "Hz ";
260 LOCATE 0,96 : ? "Mark space ratio =";
262 LOCATE 108,96 : ? duty; "% ";
266 LOCATE 0,132 : ? duty_str$
300 DO WHILE state > 0
310 GOSUB 500
320 IF state = 1 THEN
330 IF number >= 0 AND number <= 100 THEN
332 duty = number : SETPIN pwmpin,10,freq,duty
334 ELSE
336 GOSUB 900 : ? number; " - Invalid duty cycle!" : PAUSE(1000) : GOSUB 900
338 ENDIF
340 ELSEIF state = 2 THEN
350 IF number >= 1 AND number <= 5000 THEN
352 freq = number : SETPIN pwmpin,10,freq,duty
354 ELSE
356 GOSUB 900 : ? number; " - Invalid frequency!" : PAUSE(1000) : GOSUB 900
358 ENDIF
360 ENDIF
362 LOCATE 108,156 : ? FORMAT$(volt,"% .3fv ");
364 LOCATE 108,186 : ? FORMAT$(volt,"% .3vf ");
370 LOCATE 102,24 : ? FORMAT$(volt,"% .3fV ");
375 LOCATE 114,60 : ? freq; "Hz ";
380 LOCATE 108,96 : ? duty; "% ";
390 LOOP
395 SETPIN pwmpin,0
399 END
499 ' get number routine
500 GOSUB 900
510 DO WHILE 1
512 IF tick_flag = 1 THEN
514 tick_flag = 0
520 LOCATE 108,196 : ? FORMAT$(volt,"% .3fv ");
521 LOCATE 108,156 : ? FORMAT$(volt,"% .3fv ");
522 LOCATE 102,24 : ? FORMAT$(volt,"% .3fV ");
523 LOCATE 114,60 : ? freq; "Hz ";
524 LOCATE 108,96 : ? duty; "% ";
525 LOCATE LEN(numstr$) * 6,144
526 ENDIF
528 inpkey$ = UCASE$(INKEY$)
530 IF inpkey$ = "" THEN GOTO 520
540 IF inpkey$ = "Q" THEN state = -1 : EXIT
550 IF inpkey$ = "D" THEN
551 LOCATE 0,132
552 ? duty_str$
553 state = 1
554 GOSUB 900
555 GOTO 520
559 ENDIF
560 IF inpkey$ = "F" THEN
561 LOCATE 0,132
562 ? freq_str$
563 state = 2
564 GOSUB 900
565 GOTO 520
569 ENDIF
580 IF inpkey$ < "0" OR inpkey$ > "9" THEN
590 numlen = LEN(numstr$)
600 IF ASC(inpkey$) = 13 THEN
610 IF numlen = 0 THEN number = -1 ELSE number = VAL(numstr$)
620 EXIT
630 ELSEIF ASC(inpkey$) = 8 THEN
640 IF numlen > 0 THEN
650 IF numlen <> 1 THEN numstr$ = LEFT$(numstr$, numlen - 1) ELSE numstr$ = ""
660 csr = (numlen - 1) * 6
670 LOCATE csr,144 : ? " "; : LOCATE csr,144
680 ENDIF
690 ENDIF
700 ELSE
710 numstr$ = numstr$ + inpkey$
720 ? inpkey$;
730 ENDIF
750 LOOP
760 GOSUB 900
799 RETURN
899 ' clear input
900 numstr$ = ""
910 LOCATE 0,144
920 ? SPACE$(80)
930 LOCATE 0,144
999 RETURN
1099 ' settick interrupt routine
1100 tick_cnt = tick_cnt + 1
1110 tick_array(tick_cnt) = offset + (PIN(voltpin) * coefficient)
1120 IF tick_cnt <> tick_avg THEN IRETURN
1130 volt = 0
1140 FOR i = 1 TO tick_avg
1150 volt = volt + tick_array(i)
1160 NEXT i
1170 volt = volt / tick_avg
1180 tick_cnt = 0
1190 tick_flag = 1
1199 IRETURN

technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 10:51pm 05 Sep 2011
Copy link to clipboard 
Print this post

2011-09-06_085015_Maximite.zip


::: here is the hex code firm-w needed to run the program...regards sparkey...
technicians do it with least resistance
 
VK6MRG

Guru

Joined: 08/06/2011
Location: Australia
Posts: 347
Posted: 04:21pm 06 Sep 2011
Copy link to clipboard 
Print this post

Sparkey,
Is this hex code the basic program as well?
Have you imbedded the bas file into MMBasic so you don't need a sd card?

Its easier to ask forgiveness than to seek permission!

............VK6MRG.............VK3MGR............
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 04:27pm 06 Sep 2011
Copy link to clipboard 
Print this post

no i have a special hex "firm ware " that allows the pwm to run it also runs mmbasic fine as well but gerard added some command interperters into the firm....regards sparkey well i guess if it was turned into hex and then it would be free running that would be good ... may be something for the future ...
technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 01:15am 07 Sep 2011
Copy link to clipboard 
Print this post

to gerard i now have on the screen,,,::

:::main bus a v+

running freq 100 Hz


mark space ratio 50

set freq line

9v rail v+

5 volt rail v+

running up time

..i cannot get the up time to refresh if you could help me with this pls ...i am trying and finding things a bit easier to do but some things that i dont know how to do but i keep forging ahead ,,thanks sparkey....
technicians do it with least resistance
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 05:11pm 05 Dec 2011
Copy link to clipboard 
Print this post

Hi Sparkey,
Do you have PWM firmware for the new version of MMBasic (2.7A or 2.7B)?
The hardware PWM command is so significance for me.
Thanks
 
aargee
Senior Member

Joined: 21/08/2008
Location: Australia
Posts: 255
Posted: 09:44pm 05 Dec 2011
Copy link to clipboard 
Print this post

Ztoti,

Sparkey is no longer able to post, although I suspect he is reading.

Hi Sparkey!

- Rob.


For crying out loud, all I wanted to do was flash this blasted LED.
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2914
Posted: 11:03pm 05 Dec 2011
Copy link to clipboard 
Print this post

  aargee said   Ztoti,

Sparkey is no longer able to post, although I suspect he is reading.

Hi Sparkey!

- Rob.



Yes Ztoti,

Sparkey had his rights to reply removed for reasons I wont go into, I am certain he still reads this forum, which makes me smile when I see the constant sparkey teases that still occur... Its not nice and shouldnt be still continuing so long after his `removal'..

But if Sparkey is reading this and wants to send on his code he is most welcome to email me privately (he has my email address) and I can then PM it to you..


Or, I know Sparkey is active (and behaving very well I might add) on Kens forum for the DuinoMite at:


DuinoMite Forum


Edited by bigmik 2011-12-07
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 02:02am 06 Dec 2011
Copy link to clipboard 
Print this post

  ztoti said  
Do you have PWM firmware for the new version of MMBasic (2.7A or 2.7B)?
The hardware PWM command is so significance for me.
Thanks

Ztoti,
MMbasic on the Maximite can setup PWM output by re-using the audio output pins and the SOUND command which optionally sets the duty cycle. The output then keeps running until the program changes it. The details are in the Maximite User Manual which can be downloaded from Geoff Graham's website - bottom of the "Maximite" page.
http://geoffg.net/Downloads/Maximite/Maximite%20User%20Manua l%20V2.7.pdf
Edited by paceman 2011-12-07
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 05:48pm 06 Dec 2011
Copy link to clipboard 
Print this post

Paceman,
I know that, but there is just one PWM output and doesn't work in background.
ex: 10 sound 1000,1000,50
20 do
30 ' some code
40 loop
The sound of 1kHz, 50% duty, 1000 msec (1 sec) will stop after 1sec, the Sparkey's software is able to generate PWM to the next change.

What I need to do?: I have previosly project of Power Supply, I wrote the software in Proton Basic and it work perfect. http://www.youtube.com/watch?v=denryjAvtDA
I need two PWM outputs for Voltage and Current control.
I will use MaximiteBasic, 5" LCDmonitor and keypad.
That is my problem - 2PWM signals.

Thanks
ps. Sorry I have not spell checker
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 12:12pm 07 Dec 2011
Copy link to clipboard 
Print this post

  ztoti said   Paceman,
I know that, but there is just one PWM output and doesn't work in background.
ex: 10 sound 1000,1000,50
20 do
30 ' some code
40 loop
The sound of 1kHz, 50% duty, 1000 msec (1 sec) will stop after 1sec, the Sparkey's software is able to generate PWM to the next change.

Hi Ztoti,
Line 10 will give you 1KHz for 1 sec and then stop, as you say it does. That's correct according to the User Manual since the second parameter 'dur' is supposed to be in milliseconds, not seconds. I'm not sure how big a number you can put there but I assume the 'E' notation is also valid or you could assign a multiple to 'dur' ahead of the SOUND command.
Your first post didn't mention needing to control two outputs. Yes this will be a problem and I'm not the one to help here, maybe one of the hardware (software??) gurus can help.

Greg
 
Print this page


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

© JAQ Software 2024