Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMP does not power off when the calculator is off #15

Open
vladkorotnev opened this issue May 16, 2018 · 26 comments
Open

SMP does not power off when the calculator is off #15

vladkorotnev opened this issue May 16, 2018 · 26 comments
Assignees
Labels
bug Something isn't working hw hardware related

Comments

@vladkorotnev
Copy link
Owner

When the calculator is off, the module still remains powered on the VCC line.
Probably the Vcc line is just connected directly to the computer's battery input.

Proposed solutions:

  • Find if it is possible to turn it off in software
  • Rewrite using interrupts and sleep mode to lower the power consumption (preferred method)

@piotr433 Can you please chime in on how the Vcc line of the SMP socket is wired?

Thanks!

@vladkorotnev vladkorotnev added the bug Something isn't working label May 16, 2018
@vladkorotnev vladkorotnev self-assigned this May 16, 2018
@piotr433
Copy link
Collaborator

I confirm that the supply voltage is present on the SMP connector even when the calculator is turned off.

Probably the Vcc line is just connected directly to the computer's battery input.

No, not directly, but through a voltage regulator.

Find if it is possible to turn it off in software

I'm afraid it's not possible.

Rewrite using interrupts and sleep mode to lower the power consumption (preferred method)

Yes, the microprocessor should be put in sleep mode after a few seconds of bus inactivity, and waken up by a CLOCK signal.

Measurement results supplied by fellow @spark-sys:

MK-90 turned off:
no load, Vcc = 3.5V
R = 10 kohm, Vcc = 3.5V, I = 0.35 mA
R = 1 kohm, Vcc = 3.1V, I = 3.1 mA
R = 470 ohm, Vcc = 2.8V, I = 5.96 mA
R = 330 ohm, Vcc = 2.6V, I = 7.9 mA
R = 300 ohm, Vcc = 2.2V, I = 7.7 mA
R = 220 ohm, Vcc = 2.1V, I = 9.5 mA * MK-90 doesn't turn on under such load

MK-90 turned on:
no load, Vcc = 4.8V
R = 10 kohm, Vcc = 4.7V, I = 0.47 mA
R = 1 kohm, Vcc = 4.5V, I = 4.5 mA
R = 470 ohm, Vcc = 4.5V, I = 9.6 mA
R = 330 ohm, Vcc = 4.5V, I = 13.6 mA
R = 300 ohm, Vcc = 4.5V, I = 15 mA
R = 220 ohm, MK-90 doesn't turn on

@vladkorotnev
Copy link
Owner Author

Too bad, that leaves us no capacity to make a WiFi version, at least for now.
But I hope microSD can run with an Arduino with no problem off that :-)

@piotr433
Copy link
Collaborator

There's no guarantee that every MK-90 can supply 15mA. My earlier project of this kind failed, because it worked only with some of them. I guess that it drew too much current.
http://web.archive.org/web/20071102215701/http://www.pisi.com.pl/piotr433/mk90rcre.htm

Perhaps your device could be powered from the pin 39 of the rear expansion port? It's directly connected to the positive battery terminal. It's an ugly solution, I know...

@vladkorotnev
Copy link
Owner Author

Is the Vbat terminal on the SMP port powered by the MK, btw?
Maybe it can be somehow repurposed to supply power?

@vladkorotnev
Copy link
Owner Author

Also I noticed that arduino-based SMPEmu won't work if it's plugged in while the calculator is off.

I suppose this is related to the fact that standby voltage on the Vcc line of the SMP slot is 3.5V, which might be below the default BODLEVEL fuse setting by Arduino IDE.

I will also try removing the extra LEDs from the arduino to reduce current consumption.

However looking at microSD datasheets, most of them use roughly up to 50mA when writing, so it might cause a reboot of the calculator.

Seems like there is a need to somehow hardwire the emulator cartridge into the power circuits of the calculator or the battery slot...

@vladkorotnev
Copy link
Owner Author

After removing the power LED, I was able to implement the power saving mechanism in 5c17558

However some issues arised.

  1. You still need to plug in the module while the calculator is active (Vcc is at 5v)
  2. Sometimes the calculator doesn't deselect the module on time, which keeps it active and prevents it from going to sleep
  3. Sleep mode cannot be lower than SLEEP_MODE_ADC. I'm not sure what this is caused by, but the SMP seems to be unreadable with any sleep mode lower than that.

@piotr433 If you could please test in regard of point № 3 and measure the new current consumption of the module, that would be very helpful :-)

@piotr433
Copy link
Collaborator

Unfortunately, this test cannot be performed on my present ATMEGA8 board. I have just ordered an ATMEGA328 board and hope to get it within a few days.

@piotr433
Copy link
Collaborator

Thoughts without testing - the problem is surely caused by the long startup time of the crystal oscillator (milliseconds range) and the SUT configurations bits setting. Proposed solutions:

  1. Selecting the internal RC oscillator (which starts immediately) as a clock source. This choice would affect the Arduino bootloader communication reliability, though. It would be safer to burn the flash through the SPI port.

  2. Not using the microcontroller power saving features, but connecting the board through an additional circuit cutting off the power when the SMP supply voltage drops below 4V.

@vladkorotnev
Copy link
Owner Author

@piotr433 Will anything bad happen if we feed stabilized +5v into the SMP port? Because that way we could add a stabilizer and a lipo battery and turn the flash cartridge into a memory+battery pack, for even further ease of use of the calculator :-)

@piotr433
Copy link
Collaborator

Feeding +5v into the SMP port wouldn't hurt the calculator, but wouldn't power it, either. In order to be sure I have tried this on my MK-90.

@vladkorotnev
Copy link
Owner Author

OK, so maybe we could have a supercapacitor or a small battery inside our SMP to keep up with the current spikes of up to 30-50mA that an SD card can do?

@piotr433
Copy link
Collaborator

It's a good observation that the increased current demand will last only for short periods of time. I like your idea!

@vladkorotnev
Copy link
Owner Author

Do you know the proper calculation formula though? I hardly remember anything apart from the ohm's law and some RLC filters :-(

@piotr433
Copy link
Collaborator

What do you want to calculate? The capacitor value?
When a capacitor is charged or discharged with a constant current, then the voltage across it ramps linearly according to the formula:
delta U = current * time / capacitance
Assuming current spike duration of 20 ms, current value of 50 mA and allowed voltage drop of 0.1 V we get:
capacitance = 0.05A * 0.02s / 0.1V = 10 mF

@vladkorotnev
Copy link
Owner Author

10uF is easy, these days we can get even more, can we go up to 1s then?

@piotr433
Copy link
Collaborator

mF means millifarad = 1000 microfarad
10 mF = 10000 uF
Too high value would increase the loading time after power on. Loading a discharged 10000 uF capacitor with a constant current of 10 mA to 3.3 V would take:
0.01F * 3.3 V / 0.01A = 3.3 seconds

@vladkorotnev
Copy link
Owner Author

oh, I'm not sure if small 10mF caps exist (I mean, I have some, but they are about the size of a vodka shot glass :D)

yeah but those 3.3s will be after plugging in the SMP, not when turning on the calculator. It however is interesting if the high inrush current of the empty cap charging might burn the power circuitry of the calculator...

@vladkorotnev
Copy link
Owner Author

Oh, it seems they indeed do exist! https://www.digikey.com/product-detail/en/rubycon/16PX10000MEFC16X31.5/1189-1125-ND/3134083

The huge ones I have are for 60V, that's why they are so big it seems.

Probably 16V is a safe margin, as I doubt 6V or 10V ones exist, or if they do, that they are much smaller

@piotr433
Copy link
Collaborator

piotr433 commented May 18, 2018

The SMP port seems to be short-proof, but from my experience, when it is directly loaded with a capacitor > 100 uF, the calculator wouldn't turn on. A series current limiting resistor (470 ohm) would be needed.
BTW, when a capacitor is charged from a constant voltage source through a resistor, following formula applies:
obraz
The supply voltage required by an SD card is 3.3V, right? A voltage regulator would be needed between the capacitor and the card.

@vladkorotnev
Copy link
Owner Author

vladkorotnev commented May 18, 2018 via email

@piotr433
Copy link
Collaborator

Wouldn't the resistor create problems at the time the current needs to be released (e.g. During a card write)?

It would limit the SD card average current, i.e. the duty cycle (how intensively the SD card can be accessed). Some current limiter is necessary, though, otherwise the MK-90 won't turn on. Perhaps a JFET BF245C with the gate connected to source?

BTW, ensure that the capacitor is discharged before connecting it to the calculator.

@vladkorotnev
Copy link
Owner Author

JFET BF245C with the gate connected to source?

Could you please provide a schematic of what you mean?

@piotr433
Copy link
Collaborator

sch
The advantage of a JFET over a resistor is its nonlinearity. At low drain-source voltage it acts as a resistor of 120 ohm, otherwise like a current source of 16 mA (values measured on my specimen). The capacitor is loaded faster than through an ordinary series resistor of 5V / 16 mA = 312 ohm.
The circuit was tested on my MK-90.

@vladkorotnev
Copy link
Owner Author

vladkorotnev commented May 20, 2018 via email

@vladkorotnev vladkorotnev added the hw hardware related label May 22, 2018
@piotr433
Copy link
Collaborator

I had to modify the AVR program because of following issues:

  1. The subroutine recvCommand() cannot handle a SELECT pulse without CLOCK pulses (which appears on the SMP bus when a key is pressed or a beep emitted). It stays then in the WAIT_CLOCK_FALL loop consuming power. A crude fix was applied to the do_get_byte() routine.

  2. The sleep / wake up code is overly complicated.

Measured current consumption:

  1. No power saving (subroutine sleep_mode() commented out) - 10mA

  2. SLEEP_MODE_ADC - 2mA

  3. SLEEP_MODE_PWR_DOWN - less than 0.1mA (cannot measure more accurately), works only with an internal RC oscillator 8MHz with minimal startup time (HFuse=0xD9, LFuse=0xC2). This fuse modification disables the Arduino bootloader!

@vladkorotnev
Copy link
Owner Author

vladkorotnev commented May 30, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hw hardware related
Projects
None yet
Development

No branches or pull requests

2 participants