Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

how entering sleep mode
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
wimapon

Bascom Member



Joined: 26 Oct 2008
Posts: 24
Location: Meedhuizen

netherlands.gif
PostPosted: Sun Jan 03, 2021 11:58 am    Post subject: how entering sleep mode Reply with quote

Hi folks,
I am making an automatic antenna tuner.
I use an atmega128.
After setting all relais, i like to switch off the whole processor, because it gives a lot of noise on my radio receiver.
So how can i enter a sleep mode. everyting must stop. Only some output pins must stay high or low, to keep the relais
in their position.

Starting the processor again can i do with switching the power off and on again.

thanks for your help.

Wim Apon PA0SLT


(BASCOM-AVR version : 2.0.7.8 , Latest : 2.0.8.3 )
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Jan 03, 2021 12:47 pm    Post subject: Re: how entering sleep mode Reply with quote

wimapon wrote:
So how can i enter a sleep mode. everyting must stop.

The Help, available integrated, as pdf file, online, additionally containing code samples, seems to be truly the most ignored document.
To find an antenna tuner useful, you must be amateur radio operator, and as such able to read and understand English, also you should be able to find suitable documentation.
Here everything lies right in front of your nose.

Or was the purpose of this request the pure lust in communication?

Online: mcselec.com > Bascom-AVR Help > BASCOM Language Reference > CONFIGURATION > CONFIG POWERMODE
Back to top
View user's profile
wimapon

Bascom Member



Joined: 26 Oct 2008
Posts: 24
Location: Meedhuizen

netherlands.gif
PostPosted: Sun Jan 03, 2021 1:26 pm    Post subject: Reply with quote

Hi MWS,
thanks for your replay.

I do read: The modes and their exact behaviour is different on all processors. The following description from the data sheet is for the Mega88P.

the other example is for atxmega....

It is not clear for me.
I can not find what it does exactly.

so a simple question is here. If somebody knows what to do, i would be greatfull

Wim
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Jan 03, 2021 2:21 pm    Post subject: Reply with quote

wimapon wrote:
I do read: The modes and their exact behaviour is different on all processors.

At this point you would load and look up the ATM128 Datasheet, Power Managerment... > Sleep Modes.
Generally it is to say, that Power-Down leaves the least internals of AVR running and ATM128 resembles more to ATMega/ATTiny than to XMega.
Thus the help's ATTiny sample and Power-Down will be your choice, there's also a power.bas sample in the Bascom samples folder.
If you want to recover from sleep via power-toggle instead of using an external interrupt, then simply remove all the external interrupt stuff.
Back to top
View user's profile
wimapon

Bascom Member



Joined: 26 Oct 2008
Posts: 24
Location: Meedhuizen

netherlands.gif
PostPosted: Sun Jan 03, 2021 4:38 pm    Post subject: Reply with quote

Okee MWS,
now i do know more now
I will do some experiments now.
thanks for your help.

i will report my findings here.

73
Wim PA0SLT
Back to top
View user's profile Visit poster's website
wimapon

Bascom Member



Joined: 26 Oct 2008
Posts: 24
Location: Meedhuizen

netherlands.gif
PostPosted: Sun Jan 03, 2021 5:09 pm    Post subject: Reply with quote

Well, i put this at the end of my program.
the noise is still there.





'============================================================

'Didr0 = Bits(ain1d , Ain0d) 'unkown variable!! 'Disable digital input buffer on the AIN1/0 pin

'Set Acsr.acd 'Switch off the power to the Analog Comparator
'alternative:
Stop Ac

Reset Acsr.acbg 'Disable Analog Comparator Bandgap Select

'Reset Adcsra.aden 'Switch off ADC
'alternative:
Stop Adc


config powermode = powerdown

locate 2,1
lcd "***********" 'this does not come in the display, so powerdown works
'================================================================

END
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Jan 03, 2021 6:06 pm    Post subject: Reply with quote

wimapon wrote:
Well, i put this at the end of my program.
the noise is still there.

The noise originates for sure from the µC? Have you done everything to avoid noise, enough C's and shielding?
Is it gone if you pull Reset to GND? Relays will shut off then, try to manually keep some running, noise may come from the PSU too.
What clock source do you use?
As noise depends on frequency and as the ATM128 sports a XDIV - XTAL Divide Control Register, you can drive a 16MHz crystal clock down to 125kHz.
Be aware that only peripherals are affected, if you use an external crystal together with the µC's oscillator, this one may still generate noise.
Back to top
View user's profile
wimapon

Bascom Member



Joined: 26 Oct 2008
Posts: 24
Location: Meedhuizen

netherlands.gif
PostPosted: Sun Jan 03, 2021 8:44 pm    Post subject: Reply with quote

that is a good idea; i will give the by the processor choosen relais the voltage by wires, so the tuning unit will
work without the processor...

the processor is in a closed metal box and all wires to the relais and power etc, have condensors and
feed-through capacitors.

i also will try to pull reset to ground... seeing what happens.

i use the intern oscillator.
i did put it to maximum frequency by the lockbits?? or so.
because the switching must be as fast as possible.
Now to get the good swr, it takes one minute.
If i can cancel the noise, i will think about a better and faster algoritme.
I do use 21 relais. so there are a lot of possible situations of switching.
My program tries them all and remembers the best one.

i will try to get the frequency range of the noise with a spectrum analyser.
that must give some info about the origin frequency.
If that does not work i can use a sdr receiver with a waterfall display.


Wim
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Jan 03, 2021 9:54 pm    Post subject: Reply with quote

If you pull Reset to ground, then the controller enters programming mode, where all portpins beside ISP enter tristate mode.
This halts the processor. My suggestion to leave still a few relays powered on, is only because to have them draw some current.
It would show where the noise comes from, if it's the controller, the noise must disappear, if it's the PSU you will notice this also.

From your description you use the internal R/C-oscillator at 8MHz. The clock distribution scheme on page 35 of the ATM128 datasheet shows that also the R/C source is routed over the clock multiplexer. It means the 8MHz clock should be scalable via the XDiv-register. Setting it by:
Code:
XDIV = Bits(XDIVEN, XDIV0)

should divide 8 MHz by 128 = 62.5 kHz peripheral clock.
According the clock scheme flash- and eeprom-clock still would run at 8 MHz, but nonetheless above command may significantly reduce noise, if you issue it before powerdown.
Back to top
View user's profile
wimapon

Bascom Member



Joined: 26 Oct 2008
Posts: 24
Location: Meedhuizen

netherlands.gif
PostPosted: Mon Jan 04, 2021 12:07 am    Post subject: Reply with quote

Hi MWS,
if i pull reset to ground the noise dissapears and all the relais get no power.


So the noise comes from the controller.....

i will try your other suggestion ( XDIV = Bits(XDIVEN, XDIV0 ) ) tomorrow.

many thanks for your help for this day

73
Wim
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Mon Jan 04, 2021 1:12 am    Post subject: Reply with quote

Have you thought about using flip flops to drive the relays
you could then turn off everything but the relays and flip flops.
Regards Paul
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Mon Jan 04, 2021 2:55 am    Post subject: Reply with quote

Putting the AVR in power-down mode also stops the system clock and stops the noise generation.
In addition, the state of the port remains the same as it was just before the power down.

To start the AVR for re-operation, it is effective to start it by interrupting with a switch etc. as described above.

If it is necessary to constantly monitor the reception status with the AVR, separate the power supply of the AVR and the power supply of the receiver, and separate the AVR circuit and the receiving circuit with a shield.
Furthermore, it is effective to put an EMI filter in all I/O ports connected to the outside.
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Mon Jan 04, 2021 4:02 am    Post subject: Reply with quote

O-Family wrote:
Putting the AVR in power-down mode also stops the system clock and stops the noise generation.

Yes, we know the theory or what the data sheet tells, but if you'd actually have followed the thread, you'd know there is still noise in power down. Theory meets reality.
Which was the reason of further discussion.
Quote:
If it is necessary to constantly monitor the reception status with the AVR

Again, also here it helps to read the thread to learn this is not required. After finding the best solution, the relay status needs to be latched, everything else off till a power toggle.
Quote:
separate the power supply of the AVR and the power supply of the receiver,

Do you understand the topic? A tuneable antenna is used for ham radio, and if you'd have seen such receiver or transceiver, then you'd know that the very last thing the TO would do, is to open his radio to find 5V somewhere to use it for the AVR.
Of course the AVR is already powered separately, made me wonder if you try do some jokes.
Back to top
View user's profile
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Mon Jan 04, 2021 8:11 am    Post subject: Reply with quote

Hello
try to use a bistable relay and turn off the processor completely if I understood correctly you can do so. If you don't want to waste time designing shields and disrupting everything, including power.
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Mon Jan 04, 2021 11:20 am    Post subject: Reply with quote

Quote:
Yes, we know the theory or what the data sheet tells, but if you'd actually have followed the thread, you'd know there is still noise in power down. Theory meets reality.
Which was the reason of further discussion.

Remaining noise means that you are not in the exact power down mode.
Quote:
Do you understand the topic? A tuneable antenna is used for ham radio, and if you'd have seen such receiver or transceiver, then you'd know that the very last thing the TO would do, is to open his radio to find 5V somewhere to use it for the AVR.
Of course the AVR is already powered separately, made me wonder if you try do some jokes.

Yes.
I have an amateur radio callsign and have several walkie-talkies.
In addition, I have been familiar with analog and digital circuit design for over 40years.
The reason for separating the power supply is that it is quite possible that noise is radiated from the power supply.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
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