Forum: Mikrocontroller und Digitale Elektronik attiny45 two pulse


von sirlakidis g. (geosig)


Angehängte Dateien:

Lesenswert?

Good evening everyone here.
I'm NEW to Programming , and learns bascom..
create a project with attiny45 which simultaneously produces two PULSES 
in PORB.3 AND POTB.4 but unfortunately creeps the microcontrollers..
can help me on how to do it right ...
1
  $regfile = "attiny45.dat"
2
  $crystal = 1000000
3
  Config Portb = Output
4
  Const Ondelay Tx = 240
5
  Const Offdelay Tx = 9176
6
  Const 
7
  Const Offdelay = 9192
8
9
  Do
10
11
    Portb.3 = 0
12
    Waitus Ondelay Tx
13
    Portb.3 = 1
14
    Waitus Offdelay Tx
15
16
    Portb.4 = 0
17
    Waitus Ondelay
18
    Portb.4 = 1
19
    Waitus Offdelay
20
21
22
  Loop
23
24
    End
Here is the pulse that made

: Bearbeitet durch User
von Karl H. (kbuchegg)


Lesenswert?

Well. That is obviously not correct.

First of all, draw a picture which is to scale!
The most important thing is: do both pulses alwas start at the same 
time? Then you can get away with a simple solution which works with 
delays. If not, then you need something fancier using timers to do the 
timing.

But do yourself a favour and start with a scale drawing showing at least 
2 pulse periods.

: Bearbeitet durch User
von sirlakidis g. (geosig)


Lesenswert?

NO the two pulses do not start together..
The PULSE on potb.4 must start at HALF SIZE POINT OF THE ROUTE of 
portb.3

von Karl H. (kbuchegg)


Lesenswert?

sirlakidis giannis schrieb:
> NO the two pulses do not start together..
> The PULSE on potb.4 must start at HALF SIZE POINT OF THE ROUTE of
> portb.3

On each and every pulse sequence.

SO the chain of events is
1
do
2
  b3 to 1
3
  wait 40µs
4
  b4 to 1
5
  wait 40µs
6
  b3 to 0
7
  wait 200µs
8
  b4 to 0
9
  wait 9.2ms - 280µs
10
loop

both pulses are intermixed to each other. But if you follow the programm 
over time, you will see, that b3 has a total on-time of 80µs and b4 has 
a total on-time of 240µs and starts 40µs after the pulse b3 has started.

Thats why I told you to make drawing. Following that drawing on the time 
line from left to right you would have figured it out all by yourself, 
which event takes place when and what the timing has to be from one 
event to the next one.

: Bearbeitet durch User
von sirlakidis g. (geosig)


Angehängte Dateien:

Lesenswert?

yes they were WRONG starter and their two PULSES together..
yes you begin to understand what I you say..
SIMPLE hard to understand , English is not my native language..
if you with SIMPLE words

: Bearbeitet durch User
von Karl H. (kbuchegg)


Angehängte Dateien:

Lesenswert?

sirlakidis giannis schrieb:


> SIMPLE hard to understand

I see, you have done your homework.
Now go a step further, put the 2 timelines in context, introduce a 
timeline for 1 cycle and do the math (see picture)

once you know the order of events that have to take place and how many 
time has to pass by between the events, you are actually ready ... to 
put all this in a programm and off you go: the µC ist producing exactly 
the pulses as specified in your diagram. Just follow the timeline from 
left to right for 1 cycle. It will tell you what to do and how long to 
wait until the next action hast to occour.

Well not exactly, the µC will be off by a few µs, depending on the clock 
speed of the µC, but I guess it will be close enough.

Where is the problem?
Preperation and doing the math BOFORE you start coding is one of the 
keys to success.

: Bearbeitet durch User
von sirlakidis g. (geosig)


Lesenswert?

THANK YOU VERY MUCH KARI HEINZ ..
It did this successfully with the assist FINAL..

THANKS..!!!!

von sirlakidis g. (geosig)


Angehängte Dateien:

Lesenswert?

Good evening Karl Heinz..
Here's the finished project..
1
$regfile = "attiny45.dat"
2
$crystal = 1000000
3
Config Portb = Output
4
Const 
5
Const Offtx = 4360
6
Const 
7
Const Offs = 4520
8
9
Do
10
11
Portb.3 = 1
12
Waitus Ontx
13
Portb.3 = 0
14
Waitus Offtx
15
Portb.4 = 1
16
Waitus Ons
17
Portb.4 = 0
18
Waitus Offs
19
Portb.3 = 1
20
21
Loop
22
23
End


Now I want to do the following..
NEED PROTO YOU thank you very much..
Well΄ now I want to change the duration of the pulse ΤΧ with a switch.
example When arming a portb.1 ena portb.2 in +5 volt then I have a 
different UP time in tx pulse..
Show timetable..

: Bearbeitet durch User
von Karl H. (kbuchegg)


Lesenswert?

Well, it is pretty much the same.

Make a drawing. figure out, which value computes from which other value, 
do the math and ... you have all that is needed.
I will not do it for you, since i strongly believe that every 8 year old 
child can do that. It really is THAT simple as to add or subtract a few 
numbers where all you need to do is figure out which numbers have to be 
added or subtracted. If you can't do it in your mind, then make a 
drawing. That drawing will tell you all that is needed.

If you have 2 relationships
1
   |
2
   |
3
   |    |<------------- 5000 -------------->|
4
   |    |                                   |
5
   |    |<------ 2300 ------>|<----- y ---->|
6
   |
7
   +-------------------------------------------->
and know those 2 numbers and want to know the value of y, then every 8 
year old child is able to figure out, that y computes as 5000 - 2300. 
Haveing some unknown value x in that system
1
   |
2
   |
3
   |    |<------------- 5000 -------------->|
4
   |    |                                   |
5
   |    |<---- 2300 + x ---->|<----- y ---->|
6
   |
7
   +-------------------------------------------->

does not change much in that calculation. Still y computes by subtracing 
the thing left from it, which is 2300+x, from 5000. With a given and 
known value for x, it is easy to do the math in order to come up with a 
then computable value for y.

Und there really is not much more then that to solve your problem. Even 
if your specific problem is a variation of that simple principle and 
even if you need to figure out such relationships using a few easy steps 
to come up with the numbers (or formulas) needed.

it really is not that hard, to figure out how to compute the value of z 
in ...
1
   |
2
   |
3
   |    |<------------- 5800 -------------------->|
4
   |    |                                         |
5
   |    |<--- z --->|<- 80 ->|<---- 2300 + x ---->|
6
   |
7
   +-------------------------------------------------->
... even if the value for x may change, but is known.

: Bearbeitet durch User
von sirlakidis g. (geosig)


Lesenswert?

Good evening and old masters Karl Heinz..
My question this time is΄..
If I want to arm two PULSES modern (tuning)..
What DO I DO in this case????

von sirlakidis g. (geosig)


Angehängte Dateien:

Lesenswert?

See the image

von Karl H. (kbuchegg)


Lesenswert?

Your image is misleading.
You still have not learned, that an image should show all relevant 
facts.
And in this case, fact is that there is no longer a fixed phase 
relationship inbetween those 2 pulses.

Therefor you have to switch to a different strategy.
Your best option is to use timers, for what you want to do.

von sirlakidis g. (geosig)


Lesenswert?

Can you show me the way that you can use timers..
with a simple example perhaps ??

von Karl H. (kbuchegg)


Lesenswert?

The point is:
the whole thing is not THAT simple, because there are a number of 
concepts involved. Especially with a Tiny45, which does not have a 16 
Bit Timer.

If you are not experienced with using timers, it is rather long lerning 
curve and not something I can express in 30 oder 40 words.

von sirlakidis g. (geosig)


Lesenswert?

Understand okay then I read ...thanks

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.