The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Fri Apr 21, 2023 1:54 pm
by marcexec
We'll have a look at my journey to get started with the iPDM56 VCU from one of the forum's sages: @Celeron55.
While this won't be as funny or even verbose as @Gregski's style I will try to document this very beginner-friendly and there will be no question too stupid as long as it's on topic. This includes feature requests i.e. "how would I ...".
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Fri Apr 21, 2023 9:06 pm
by nkiernan
Excellent I should have one landing in the post very soon too so can join in
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Thu Apr 27, 2023 7:46 pm
by marcexec
Better a small update than none:
Have wired up the ISA current sensor & resistor, but still need to take the board out to replace R97 & solder jumper connectors for the CAN termination.
/*
ipdmsw - iPDM56 firmware template
Copyright (c) 2023 Perttu "celeron55" Ahola
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "src/ipdm_library.h"
#include "src/ipdm_util.h"
#include "src/ipdm_can.h"
#include "src/params.h"
// Matrix inputs/outputs
constexpr int UNUSED_M1 = A0; // A0 = M1
constexpr int UNUSED_M2 = A1; // A1 = M2
constexpr int UNUSED_M3 = A2; // A2 = M3
constexpr int UNUSED_M4 = A3; // A3 = M4
constexpr int UNUSED_M5 = A6; // A6 = M5
constexpr int UNUSED_M6 = 2; // D2 = M6
constexpr int UNUSED_M7 = 3; // D3 = M7
constexpr int UNUSED_M8 = ipdm::ED4; // ED4 = M8
constexpr int UNUSED_M9 = ipdm::ED5; // ED5 = M9
constexpr int UNUSED_M10 = ipdm::ED6; // ED6 = M10
// Outputs
constexpr int UNUSED_LOUT1 = ipdm::LOUT1;
constexpr int UNUSED_LOUT2 = ipdm::LOUT2;
constexpr int UNUSED_LOUT3 = ipdm::LOUT3;
constexpr int UNUSED_LOUT4 = ipdm::LOUT4;
constexpr int UNUSED_LOUT5 = ipdm::LOUT5;
constexpr int UNUSED_LOUT6 = ipdm::LOUT6;
constexpr int UNUSED_HOUT1 = ipdm::HOUT1;
constexpr int UNUSED_HOUT2 = ipdm::HOUT2;
constexpr int UNUSED_HOUT3 = ipdm::HOUT3;
constexpr int UNUSED_HOUT4 = ipdm::HOUT4;
constexpr int UNUSED_HOUT5 = ipdm::HOUT5;
constexpr int UNUSED_HOUT6 = ipdm::HOUT6;
constexpr int UNUSED_AOUT1 = ipdm::AOUT1;
constexpr int UNUSED_AOUT2 = ipdm::AOUT2;
void setup()
{
Serial.begin(115200);
ipdm::setup();
// The MCP2515 CAN controllers will be initialized with these speeds and
// filters when the 5Vsw rail is powered up using ipdm::enable_switched_5v()
ipdm::can1_params.speed = CAN_500KBPS;
ipdm::can2_params.speed = CAN_500KBPS;
// You can set the CAN filters like this. By default all messages pass.
/*ipdm::can1_params.filter1_mask = 0xfff;
ipdm::can1_params.filter1_ids[0] = 0x123;
ipdm::can1_params.filter1_ids[1] = 0x456;
ipdm::can1_params.filter2_mask = 0xff0;
ipdm::can1_params.filter2_ids[0] = 0x120;
ipdm::can1_params.filter2_ids[1] = 0x340;
ipdm::can1_params.filter2_ids[2] = 0x560;
ipdm::can1_params.filter2_ids[3] = 0x780;*/
}
void loop()
{
ipdm::loop();
EVERY_N_MILLISECONDS(30000){
ipdm::util_print_timestamp(Serial);
Serial.println("-!- iPDM56 running");
REPORT_UINT16_HYS(analogRead_mV_factor16(ipdm::VBAT_PIN, ipdm::ADC_FACTOR16_VBAT), 100);
}
// Consider D7 (IN10) to be the ignition pin and switch 5Vsw according to it
//if(ipdm::digitalRead(IGNITION_PIN)){
// Always enable switched 5V for testing CANbus
if(true){
ipdm::enable_switched_5v();
} else {
ipdm::disable_switched_5v();
}
// Read incoming CAN frames
// ipdm::can_receive(ipdm::can1, handle_can1_frame);
// ipdm::can_receive(ipdm::can2, handle_can2_frame);
// Print out (12V) battery voltage
EVERY_N_MILLISECONDS(1000){
REPORT_UINT16_HYS(analogRead_mV_factor16(ipdm::VBAT_PIN, ipdm::ADC_FACTOR16_VBAT), 100);
}
}
static void print_frame(const CAN_FRAME &frame)
{
Serial.print("id=0x");
Serial.print(frame.id, HEX);
for(uint8_t i=0; i<8; i++){
Serial.print(" 0x");
Serial.print(frame.data.bytes[i], HEX);
}
}
void handle_can1_frame(const CAN_FRAME &frame)
{
#if 1
Serial.print("CAN1 received frame ");
print_frame(frame);
Serial.println();
#endif
}
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Mon May 01, 2023 8:05 pm
by marcexec
First success!
I have soldered the jumpers in and replaced R97 (next to the MCPs) with a 1k through hole one.
Following that, with
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Wed May 17, 2023 10:03 am
by marcexec
Well, that was one evening mostly wasted:
[*] RF600 wiring colours don't match with the RF400... At least the connector pinout seems to be the same
[*] probably busted the temp gauge with 12V applied...
[*] couldn't get the RPM gauge to move with function generator of my hobby charger. Probably have to take it out to bench test with the iPDM56.
[*] labelled the wires for some of the idiot lights at least
Also ordered a second 56pin connector that I can keep wired in the bike as I add features on the bench. I think I found a location last weekend with some CAD, will make a compartment.
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Wed May 17, 2023 11:55 am
by Uppertown
marcexec wrote: ↑Wed May 17, 2023 10:03 am
[*] probably busted the temp gauge with 12V applied...
A lot of older gauges are run at around 9V through a voltage regulator, but I would have thought it would survive 12V at least for a while. Is it just stuck at the top of the scale? perhaps a little percussive maintenance is needed??
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Fri May 19, 2023 9:56 am
by marcexec
You might be right. I removed the gauges (and cleaned them) yesterday and realized I should probably have done that from the start.
Well, lesson learned - take the gauges out to bench test, guys.
It looks indeed to be stuck just under the plexiglass cover.
I'll whip up something this weekend.
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Wed Jun 07, 2023 4:00 pm
by nkiernan
Edit: My understanding is the IPDM can read 12V input signals directly (eg: from a gear selector switch), but before I potentially damage anything wanted to check in case this needs a resistor divider setup to convert back to 5V for the MCU at the matrix, or just use relevant pull-up and pull-down resistors for the high/low digital inputs? Have you tried any digital I/O yet?
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Thu Jun 08, 2023 9:46 am
by marcexec
nkiernan wrote: ↑Wed Jun 07, 2023 4:00 pm
Edit: My understanding is the IPDM can read 12V input signals directly (eg: from a gear selector switch), but before I potentially damage anything wanted to check in case this needs a resistor divider setup to convert back to 5V for the MCU at the matrix, or just use relevant pull-up and pull-down resistors for the high/low digital inputs? Have you tried any digital I/O yet?
You should be fine, the example uses M10 as "ignition". I haven't tried it yet, though.
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Tue Jun 27, 2023 8:09 pm
by nkiernan
Wondering if you've done any testing sending and receiving extended CAN frames? How do you indicate its extended do you know?
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Tue Jun 27, 2023 8:29 pm
by celeron55
Oh, sorry, I think I haven't thought that though yet as I haven't needed extended frames for anything in my projects so far.
Keep me updated how stuck you get, I'll look into it later.
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Tue Jun 27, 2023 8:36 pm
by nkiernan
Ah, OK. Thought I was missing something obvious. Will take a look at the library. Looks like some sketches can auto detect so I'll check that too
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Thu Jun 29, 2023 8:19 pm
by nkiernan
celeron55 wrote: ↑Tue Jun 27, 2023 8:29 pm
Oh, sorry, I think I haven't thought that though yet as I haven't needed extended frames for anything in my projects so far.
Keep me updated how stuck you get, I'll look into it later.
Did some more testing and checking through the libraries. Using Savvycan I've checked sending standard and extended CAN frames both to and from the ipdm. Adding the 'frame.extended' parameter below compiles but regardless of 0 or 1, it seems to default to standard CAN (code snippet shown below). Savvycan gets id 0x220
I've not figured out yet how ipdm CAN interacts with the CAN libraries but wondering if 'ipdm_can' section below could be part of it. More testing to do CAN data appears to be ok, just the id's to be figured out
typedef struct
{
uint32_t id = 0; // EID if ide set, SID otherwise
uint32_t fid = 0; // family ID
uint8_t rtr = 0; // Remote Transmission Request
uint8_t priority = 0; // Priority but only important for TX frames and then only for special uses.
uint8_t extended = 0; // Extended ID flag
uint16_t time = 0; // CAN timer value when mailbox message was received.
uint8_t length = 0; // Number of data bytes
BytesUnion data; // 64 bits - lots of ways to access it.
} CAN_FRAME;
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Wed Jul 19, 2023 8:29 am
by raine
Hi, I have been testing ipdm56 now on the bench. Looks good. However, I see CAN libraries does not support speed 83.3kbps. I think some other variations of the mcp_can, such as Longan labs version, support this rare speed, but it is with 16MHz clock. I think I saw in the schema a 8MHz oscillators for CAN. Would the Longan libraries work with the iPDM hw? Or how should I move forward? Thanks!
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Fri Jul 21, 2023 9:42 am
by celeron55
I think it should be possible to set that up, it's just a matter of setting the CNF1/2/3 register values in the MCP2515 according to its datasheet.
The problem is, I tried to wrap my brain around these for about half an hour now and haven't yet figured it out...
The MCP2515 is capable of syncing up to slight errors in bit speed so not getting it 100% right may not be an issue. But that's also why the register config is so confusing.
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Tue Jul 25, 2023 1:01 pm
by raine
celeron55 wrote: ↑Fri Jul 21, 2023 9:42 am
The problem is, I tried to wrap my brain around these for about half an hour now and haven't yet figured it out...
Glad others are struggling with register settings, so not only me. I keep trying.
My another strugle with the board is, I am able to get the program running on it and it seems to work fine, but only if usb cable is connected. So it looks like it is not getting powered with 12V. The sample program even reports the Vin voltage, so it is powered. I have even wired all +12V's and all GND's, but not getting the board powered. I am likely missing something fundamental.
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Tue Jul 25, 2023 1:55 pm
by marcexec
raine wrote: ↑Tue Jul 25, 2023 1:01 pm
Glad others are struggling with register settings, so not only me. I keep trying.
My another strugle with the board is, I am able to get the program running on it and it seems to work fine, but only if usb cable is connected. So it looks like it is not getting powered with 12V. The sample program even reports the Vin voltage, so it is powered. I have even wired all +12V's and all GND's, but not getting the board powered. I am likely missing something fundamental.
post a picture of your setup
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Tue Jul 25, 2023 3:17 pm
by raine
marcexec wrote: ↑Tue Jul 25, 2023 1:55 pm
post a picture of your setup
Here it comes. If only red (+12V) and black (gnd) at my fingers are connected, shouldn’t the unit wake up and led glow?
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Wed Jul 26, 2023 8:07 am
by AdrianB
raine wrote: ↑Tue Jul 25, 2023 3:17 pmIf only red (+12V) and black (gnd) at my fingers are connected, shouldn’t the unit wake up and led glow?
In a word yes. Double check the wiring and you should also be able to do continuity checks by following the circuits on the board back from the 12v + and - pins to the various components. Starting with where the pins are soldered to the board.
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Thu Jul 27, 2023 7:56 am
by celeron55
Once you feed 12V (8V to 16V) to those pins, the white LED should light up, and code should run.
What does happen when you do it?
The regulator U4 near those pins is a good place to start probing with a voltage meter. The ISP header has the AVR's 5V exposed so that's also a starting point (or more like the ending point).
Re: The Hitchhiker's guide to Celeron55's iPDM56 VCU & automotive Arduinoing
Posted: Sun Jul 30, 2023 9:34 am
by raine
Luckily I have a second unit at hand and after soldering the connector to it, I plugged in the connector of the first unit to it for test. And yes, it works. Leds illuminate, so the first one was a DoA.
The second unit is working fine and I have managed to get Digital outputs (logic level, lout, hout) working like expected. However, I am still struggling with aouts and lpwms. I didnt succeed with the sample code for usage of the pwm. So if something to wish, is bit more howto use examples for those please.
But positive progress. I am sure, will get it fully working afterall.