Hello from Yorkshire

Please read this if you are new to the STM32
User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Hello from Yorkshire

Post by BennehBoy » Thu Jan 05, 2017 8:34 pm

Hi,

Stumbled upon STM32 & Maple Mini whilst casting about for Arduino Nano upgrades.

I'm working on an in car multi gauge for my Land Rover. Initialling monitoring turbo boost pressure, EGT, gearbox oil temp, engine oil temp & pressure.

The system outputs to 3x SPI 0.96" OLED displays with user input to rotate the inputs around - leftmost display has a scaled graphical gauge for 1 input, the 2 right hand ones each show 2 inputs each.

I'm using a MAX31856 for the EGT, this connects via SPI.

The libraries I'm using from adafruit for the SPI devices don't coexist on the same bus happily so I'm running out of pins on the Nano, especially for intended future upgrades: 5 way tactile input, k-line connectivity with the vehicle EMS.

I'm also pretty close to the bone sram wise due to requiring a framebuffer for the OLED's - I'm displaying a number of bitmap images.

Little video from an early development phase:
[youtube]https://www.youtube.com/watch?v=tRCbjazjQy8[/youtube]

Fingers crossed that I don't hit any massive library issues now that I've already ordered some Chinese knock of maple minis!

Cheers,

Ben
-------------------------------------
https://github.com/BennehBoy

User avatar
RogerClark
Posts: 5926
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Hello from Yorkshire

Post by RogerClark » Thu Jan 05, 2017 10:01 pm

Welcome...

@nutsy is building a display for his motorbike, but I think what he wants is considerably different from what you are doing, however you may want to compare notes, so you could try PM'ing him

Re: SPI

You can run 2 SPI's on the basic "Blue Pill" STM32F103C8, but depending on the libs you may either need to modify the lib to use SPI 2 or call SPI.setModule(2); just before you use the functions for a device connected to SPI 2
(then call SPI.setModule(1); to set the SPI object back to using the SPI 1 pins)

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hello from Yorkshire

Post by BennehBoy » Thu Jan 05, 2017 10:48 pm

Thanks for the tip. I've been using software SPI on the Nano, but dual h/w SPI sounds very nice.

These are the boards that I purchased -> http://www.ebay.co.uk/itm/152115041250

Bit of an impulse buy so hopefully I've not picked up a set of duffers :D
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hello from Yorkshire

Post by BennehBoy » Thu Jan 05, 2017 11:14 pm

Just been looking at @nutsy's code, he's a bit more ambitious with the use of interupts, but then my displays don't need to be particularly realtime because they are all monitoring relatively slow changing sensors.

I'm simply doing a millis comparison to see if an interval has been reached, scraping the sensor values, and redrawing the screen. If user input is detected the interval is ignored and a redraw/sensor read triggers immediately. See below. Plenty of room for code tidy/elegance - that first if for example :D

Code: Select all

void loop() {

  unsigned long currentMillis = millis();

  // USER INTERACTION
  bool butVal = digitalRead(8); // read the button state
  if (butVal == HIGH) { 
    // do nothing if it's not pressed (pullup).
  } else { // rotate the screens if the button was pressed
    rotation = rotation + 1;
    previousMillis = previousMillis - (interval + 1); // force an update of the screens.
    if (rotation == 5) {
      rotation = 0;
    }
  }

  if (currentMillis - previousMillis > interval) { // only read the sensors and draw the screen if 250 millis have passed
    // save the last time we updated
    previousMillis = currentMillis;

    // SENSOR READING

    sensevals[0] = readBoost(0); // read boost off A0
    updatePEAK(0); // TURBO

    sensevals[1] = readERR2081(1); // read A1, currently the Gearbox oil temp sensor
    updatePEAK(1); // TBOX OIL TEMP

    sensevals[2] = readMAX(2); //read EGT from the Max31856
    updatePEAK(2); // EGT

    sensevals[3] = readPress(3);
    updatePEAK(3); // OIL PRESSURE

    sensevals[4] = readERR2081(4); // read A4, currently the Engine oil temp sensor
    updatePEAK(4); // OIL TEMP

    // DRAW DISPLAYS
    drawDISPLAY1();
    drawDISPLAY2();
    drawDISPLAY3();
  }
}
-------------------------------------
https://github.com/BennehBoy

User avatar
RogerClark
Posts: 5926
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Hello from Yorkshire

Post by RogerClark » Fri Jan 06, 2017 3:01 am

The boards you have bought should work well, (unless they are a factory reject etc)

They come pre-installed with a bootloader, so you just need to load the windows driver and you should be able to upload.

We have a wiki page for the board http://wiki.stm32duino.com/index.php?title=Maple_Mini

You can update the bootloader, which will free up 3k of RAM and about 12k of Flash (not that you are likely to need more flash)
(The wiki has details of the bootloader updater)

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hello from Yorkshire

Post by BennehBoy » Fri Jan 06, 2017 11:44 am

Great, thanks for the bootloader heads up.
-------------------------------------
https://github.com/BennehBoy

HexTank
Posts: 44
Joined: Fri Sep 30, 2016 10:46 am

Re: Hello from Yorkshire

Post by HexTank » Fri Jan 06, 2017 12:44 pm

Welcome, from Yorkshire, south.

deedaaa

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hello from Yorkshire

Post by BennehBoy » Fri Jan 06, 2017 3:19 pm

Can never get away from the deedaa's - I married one :D

From 'Udders mesen.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hello from Yorkshire

Post by BennehBoy » Fri Jan 06, 2017 3:24 pm

BTW could anyone point me at a good reference for doing analogue voltage translation from 5v to 3.3v

Many of the sensors I'm using output from 0-5v which obviously hasn't been an issue for me on the Nano.

There are many examples out there on the internet but as with all things everyone seems to have a differing opinion....
-------------------------------------
https://github.com/BennehBoy

racemaniac
Posts: 398
Joined: Sat Nov 07, 2015 9:09 am

Re: Hello from Yorkshire

Post by racemaniac » Fri Jan 06, 2017 3:40 pm

BennehBoy wrote:BTW could anyone point me at a good reference for doing analogue voltage translation from 5v to 3.3v

Many of the sensors I'm using output from 0-5v which obviously hasn't been an issue for me on the Nano.

There are many examples out there on the internet but as with all things everyone seems to have a differing opinion....
ehh, just a voltage divider? 2 resistors (or a potentiometer, then you've got an adjustable voltage divider)
https://en.wikipedia.org/wiki/Voltage_divider

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest