I think something is screwed up with the Macchina’s J1850 circuit.
When I upload the extremely simple sketch:
unsigned long duration;
unsigned long timeout;
void setup() {
// pinMode(DS7_BLUE, OUTPUT);
pinMode(J1850_VPW_RX, INPUT);
// pinMode(PS_J1850_9141, OUTPUT);
SerialUSB.begin(115200);
// digitalWrite(PS_J1850_9141, LOW);
}
// the loop function runs over and over again forever
void loop() {
duration = pulseIn(J1850_VPW_RX, HIGH, timeout);
if (timeout < 1000){
if ((duration < 210) && (duration > 190)){
SerialUSB.println();
SerialUSB.print("SOF ");
// digitalWrite(DS7_BLUE, HIGH);
}
if (duration < 190){
// digitalWrite(DS7_BLUE, HIGH);
SerialUSB.print(duration);
SerialUSB.print(" ");
}
}
//digitalWrite(DS7_BLUE, LOW);
}
It outputs some pulse width times, but its NOT the same as what my Arduino Uno/MCZ33990 outputs.
This sketch is very basic, all it does is measure a HIGH pulse on the VPW line, time how long the pulse is, and print it to the serial window.
It works perfectly on the Arduino Uno/MCZ33990…shows the initial ~200uS start of frame pulse, etc etc.
The Macchina, with the same exact sketch loaded, shows random pulse measurements…its not measuring the pulses correctly. Its supposed to show a 200uS start of frame, and then alternate between ~64uS pulses and ~128uS pulses.
Macchina just shows pulses of random lengths.
So its either not measuring things correctly, the serial output is messing up timing, the Macchina “pulseIn” works differently, something is getting blocked…or worst case scenario, the Macchina’s J1850-VPW circuit design is simply just wrong/poor.
Ben