Home-made MS2 "dashboard"

This is a forum for discussing the development and testing of alpha MS2/Extra code. Documentation
(Runs on MS2 and Microsquirt)

Moderators: jsmcortina, muythaibxr

Post Reply
robs
Master MS/Extra'er
Posts: 564
Joined: Sun Jan 17, 2010 4:26 pm
Location: Sydney, Australia

Home-made MS2 "dashboard"

Post by robs »

I've been pretty quiet in this forum lately -- other things having taken priority for a while -- but I haven't been completely idle on the MS front.

It's been a long ambition of mine to get a better understanding of electronics. I've now built a few things entirely of my own design, and they all seem to be working pretty well. The most recent was a mini-dashboard to talk to my Megasquirts and display various figures on a cheap LCD1602 display. I've written it up at: $10 Megasquirt Dashboard. Had it in mind to call it millitune in honour of the old megatune. Fortunately I resisted the urge.

A couple of things:
  • I'd be interested in any comments or criticisms of the electronics. It is my own design and I'm just fumbling my way through. Perhaps there's a smarter way to do the power supply, or maybe there's some circuit protections I should add in case of component failure.
  • The race condition described in the .. um .. 5th last paragraph might be of interest to the MS2 development audience. Possibly also to TunerStudio development. I'll go into a bit more detail here than the above link covered
Occasionally there have been postings from people who have got into difficulties turning their cars on with a laptop connected. They don't hear the pump prime, and the laptop doesn't see a MS. What's happened is that the MS has entered "monitor" mode, just as if the boot jumper had been set to burn flash. The first few instructions in the boot ROM examine the serial receive port iand, if it is at logic low, the code jumps into monitor mode. I have previously made use of this behaviour by sending a continuous RS-232 break signal to force the MS into monitor mode at startup.

Here is the pertinent bit of the boot ROM:

Code: Select all

3F:f800  18 0b 00 00 11     MOVB   #0x00,0x0011     ; MMC1.INITRG
3F:f805  18 0b 39 00 10     MOVB   #0x39,0x0010     ; MMC1.INITRM
3F:f80a  4f 1c 30 05        BRCLR  0x1c,#0x30,0xf813; MMC3.MEMSIZ0
3F:f80e  18 0b 09 00 12     MOVB   #0x09,0x0012     ; MMC1.INITEE
3F:f813  87                 CLRA
3F:f814  f6 f7 fe           LDAB   0xf7fe
3F:f817  51                 COMB
3F:f818  27 28              BEQ    0xf842
3F:f81a  1c 02 5c 20        BSET   0x025c,#0x20     ; PIM.PERP
3F:f81e  1c 02 4d 01        BSET   0x024d,#0x01     ; PIM.PPSS pull down Rx
3F:f822  1c 02 4c 01        BSET   0x024c,#0x01     ; PIM.PERS pull enable Rx
3F:f826  c7                 CLRB
3F:f827  04 31 fd           DBNE   B,0xf827
3F:f82a  f6 02 58           LDAB   0x0258           ; PIM.PTP
3F:f82d  c5 20              BITB   #0x20
3F:f82f  27 11              BEQ    0xf842
3F:f831  1f 02 48 01 0c     BRCLR  0x0248,#0x01,0xf842; PIM.PTS monitor if Rx low
3F:f836  1d 02 4d 01        BCLR   0x024d,#0x01     ; PIM.PPSS
3F:f83a  1d 02 4c 01        BCLR   0x024c,#0x01     ; PIM.PERS
3F:f83e  05 fb ff bc        JMP    [0xffbc,PC]
;
; Monitor mode
So it can end up in the monitor (0xf842) either by boot jumper (PTP[5]) or by Serial Rx pin (PTS[0]).

I toyed with the idea of putting hardware delays of some sort on the MS so that I could ensure that the dash was asserting logic 1 before the MS booted. This seemed pretty klunky. What I have done instead is also pretty klunky. Dash just checks if it is receiving the monitor mode prompt (a 3-byte sequence ending with >) and, if it is, it sends an appropriate monitor-mode command to cause the MS to reset. The command string is A2,00,3C,01 -- which writes a 1 to 0x003C, the COPCTL register. This causes a reset in a couple of milliseconds. When it comes up, dash is waiting for it with the RS-232 in the right state. It might be that TunerStudio could do the same check and hack and avoid the problems some people have had. OTOH, if the problem is something chronic in their USB RS-232 adaptors, I guess the hack won't help.

But one thing really puzzles me. In the above code, PTS[0] is put into pull down mode and is then checked for logic low. Surely this means that, unless there's something plugged into the Rx line holding it high, the test is always going to find zero at the pin? So how do our Megasquirts ever manage to boot at all when there's nothing plugged in?

Obviously reality is that it works but I'd like to know how.

Have fun,

Rob.
socrace
MS/Extra Newbie
Posts: 9
Joined: Sun May 26, 2013 8:51 am

Re: Home-made MS2 "dashboard"

Post by socrace »

The dashboard would be great for my motorcycle, esp if it can be made brighter than my current smartphone running tunerstudio.
Concerning the monitor branch, If the rs232 Rx line is floating, the max3221 outputs a high to the micro's Rx pin, so no branch to the monitor code.
Since the max3221 inverts, it takes a high rs232 Rx to force a low micro Rx pin, and a monitor branch. Seems like this could certainly happen if tunerstudio is running and interrogating while the micro powers up!
1981 Goldwing motorcycle - microsquirt'd, other stuff
robs
Master MS/Extra'er
Posts: 564
Joined: Sun Jan 17, 2010 4:26 pm
Location: Sydney, Australia

Re: Home-made MS2 "dashboard"

Post by robs »

Ah, many thanks. Explains how the hardware behaves. Putting the pin in pull-down mode still looks wrong; confusing, though not important. The one quick check in the monitor code is pretty slipshod too, but I guess B&G were not all that focussed on the monitor code when they included it; they probably didn't want an RS-232 way of entering the monitor at all, just as long as they had a way to burn the interesting stuff.

I opted for a white on blue backlit LCD. It has remained readable in all conditions, but not great in direct sunlight where the white appears dark, so you have black on blue. There are a lot to choose from though and I was thinking of buying some others myself. Will probably put a trimmer on the contrast pin when I do. Perhaps a non-backlit one would be best for a bike, or with the backlight only powered at night.

I've made a worthwhile change to the code to support reflashing the bulk of the code via RS232 (Vectors, ISRs and the flashing code itself stay resident in the top 2k). Having had to pull it out of the car's dashboard twice to get at the chip, I decided to bite the bullet. Probably won't need to change the code again :-)

Have fun,

Rob.
robs
Master MS/Extra'er
Posts: 564
Joined: Sun Jan 17, 2010 4:26 pm
Location: Sydney, Australia

Re: Home-made MS2 "dashboard"

Post by robs »

I have added a couple of photos at the link in the first posting -- for those who don't think the thousand words is as good.

Have also ordered a green background LCD, just to see how it performs in different light conditions.
Have fun,

Rob.
MS2tester
Master MS/Extra'er
Posts: 606
Joined: Sat Apr 11, 2009 12:54 pm
Location: Aalsmeer the netherlands
Contact:

Re: Home-made MS2 "dashboard"

Post by MS2tester »

would it not be a better idea to look for circular screens from the start
maybe in combination with a raspberry pi
to make it easy to update to future developments

this is coming from somebody who still has a megaview in the drawer
and the later lcd dash wich is no longer sold by diyautotune

and on top of that be able to keep the price down bare minimum
since everybody will already have spare smart phones lying around :mrgreen:
robs
Master MS/Extra'er
Posts: 564
Joined: Sun Jan 17, 2010 4:26 pm
Location: Sydney, Australia

Re: Home-made MS2 "dashboard"

Post by robs »

Going graphical would certainly be better looking, and make fast changing things like RPM more useful, but it would also complicate things quite a bit. To do it "properly", you'd need to support something like the TunerStudio gauge specs in the INI file. And, yes, doing this would probably call for something powerful like a Raspberry Pi. But "better" depends on what you want, and I'm actually pretty happy with what it is right now. I could always read RPM from the car's tacho, but the new instrument lets me watch my choice of MAP,PW, CLT,MAT, etc., which I couldn't do before.

I certainly don't see any commercial prospects in it; it was a way to learn a little more electronics while getting something I wanted. I wrote it up and linked here in case anybody else might find it useful or would want to build on it.

Have fun,

Rob.
Post Reply