Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:04 23 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 : this may be a hard one sq- wave soft wha

Author Message
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 11:59pm 29 Jul 2011
Copy link to clipboard 
Print this post

i need a programme to be able to produce an approxx 50- 100 Hz square wave and also be able to adujst the "m-s-ratio" "marc space ratio" is this possable ..look guys i`m a hard whare man even tough most of my time was with "dos" even though basic has been round for like for ages before dos ..."ccw:"any help would be appreactied
technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 12:24am 30 Jul 2011
Copy link to clipboard 
Print this post

ok guy`s if ya really want to rack your brains out may it be possible to produce two square waves on two out put pins that are in sync so there fore it would run insync looking at apair of "tip 31" or even a pair of bc 640`s does not matter what matters is that one pin is high and one is low ...ok so i use a centre tapped transformer well the rset is history thanks to any body up to the challange ...
technicians do it with least resistance
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 12:57am 30 Jul 2011
Copy link to clipboard 
Print this post

Hi.

Should be able to knock up some code to do this, ensuring that both pins are never on at the same time.

Unfortunately I have to head off to Brisbane for the rest of the weekend, so will not be able to post some code till Monday. If no-one else jumps in I will post something then.

regards

Gerard (vk3cg/vk3grs)

Regards

Gerard (vk3cg/vk3grs)
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 02:09am 30 Jul 2011
Copy link to clipboard 
Print this post

thanks gerard that will be fantastic its to run my inverter if you had not guessed
:i would also like to add that i can use a "bc-549"to pull the pin into low mode or earthed if you get what i mean ..so that the pin does not have to be read 1000 times and a average formed from this ...most cases they just tell u to wire a 4 point 7 K to ground ...if i stand correct...but i found that a transistor works a lot better Edited by sparkey 2011-07-31
technicians do it with least resistance
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 08:54am 01 Aug 2011
Copy link to clipboard 
Print this post

Hi.

Here is some code that will generate a square wave at approximately 100Hz.

The mark/space ratio can be varied from 10% to 90% in 10% increments.

The code places the output on 2 pins, with one being the inverse of the other (with a very slight delay in the 2 pin's values changing as I can not set it with one statement). The code is written such that both pins will never be on at the same time.

The 100Hz frequency is about as high as you would want to go if using pure MMBasic code. Unfortunately, none of the I/O pins have a connection to the peripheral PWM module. However, if you can solder to one of the unused MCU pins then this capability could be provided.

Regardless, I will soon release a modified version of the firmware that will allow PWM output on any of the I/O pins (or maybe only pins 1 - 10). This will be implemented using interrupts so will not be as efficient as using the PWM module. Also, the frequency range will be less - but what values I will allow I have not yet decided.

Anyway, here is the code that I hope Sparkey is after:


100 ' initialise state and I/O pins
110 markpin = 1 'set the "normal" output to logical pin 1
120 spacepin = 2 'set the inverse output to logical pin 2
130 pin(markpin) = 1 'set initial state to on
140 pin(spacepin) = 0 'set initial state to off
150 setpin markpin,8 'set pin as digital output
160 setpin spacepin,8 'set pin as digital output
170 msr = 5 'set initial mark/space ratio at 50%
180 msrtimer = 0
190 settick 1,1000 ' set tick interrupt for every millisecond

200 cls
210 locate 0,0
220 ? "Mark/Space ratio is "; msr * 10;"%"
230 ? "Enter Mark/Space ratio (1 - 9 for 10% - 90%) or 'Q' to quit"
240 inpkey$ = ucase$(inkey$)

300 do while inpkey$ <> "Q"
310 key = asc(inpkey$) - asc("0")
320 if key < 1 or key > 9 then goto 380
330 msr = key
340 locate 0,0
350 ? "Mark/Space ratio is "; msr * 10;"%"
370 ? "Enter Mark/Space ratio (1 - 9 for 10% - 90%) or 'Q' to quit"
380 inpkey$ = ucase$(inkey$)
390 loop
400 end

999 ' settick interrupt routine
1000 msrtimer=msrtimer+1
1010 if msrtimer=msr then
1020 pin(markpin)=0:pin(spacepin)=1
1040 elseif msrtimer>=10 then
1050 msrtimer=0:pin(spacepin)=0:pin(markpin)=1
1080 endif
1090 ireturn


Regards

Gerard (vk3cg/vk3grs)Edited by seco61 2011-08-02

Regards

Gerard (vk3cg/vk3grs)
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 03:03pm 01 Aug 2011
Copy link to clipboard 
Print this post

thanks gerard regards sparkey
technicians do it with least resistance
 
sparkey

Senior Member

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

well i have the maxi running my inverter but need to boost the voltage of the square wave ... i should be able to do this with a step up transitor but as yet havenot done this....
technicians do it with least resistance
 
Print this page


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

© JAQ Software 2024