Notifications
Clear all

RS485 master/slave control of 1/12 scale model Locomotives via arduino mega boards

15 Posts
3 Users
0 Reactions
258 Views
(@waynea)
Member
Joined: 2 years ago
Posts: 6
Topic starter  

I am having trouble with finding examples of master/slave control using RS485 modules communicating from a master to 3 slaves.  Currently, I have been using NRF24L01 radios to do this but it has been very unreliable.  To ensure reliability, I am going over to a 2 wire system using the RS485 modules for the communications.

The models that the system is used on are 1/12th scale models of New South Wales Railways (Australia) diesel locomotives.  Each one is powered by a single cylinder petrrol engine driving thru a centrifical clutch to a reversing gear box.  Then via a chain drive to all wheels.  In the drive system there is a disc brake for slowing/stopping the locomotive.  Also, on each locomotive is a set of 8 relays that control the lights and horns.

For control of the engine, gearbox and disc brake of have used servo motors for each of the functions.

The following is the existing Master control Arduino sketch:-

#include <SPI.h>
#include "printf.h"
#include "RF24.h"

struct deviceMap
{
// ---- mapping
uint8_t pin; // Physical pin
uint8_t dataIdx; // This is also used to map the bit in the data.relays
// ---- display only
uint8_t deviceIdx; // This is the "friendly" number e.g. 22 to match your mappings
char deviceName[33]; // Name for display
};

struct controlMessage
{
uint8_t throttle;
uint8_t brake;
uint8_t reverser;
uint32_t relays;
};

/*
nrf24l01+ Seed Modules:
NRF | Jumper | Arduino Nano | Arduino Mega
1 GND | Black | GND | GND
2 VCC | White | 3V3 | 3V3
3 CE | Grey | D7 | 8
4 CSN | Purple | D8 | 53
5 SCK | Blue | D13 | 52
6 MOSI | Green | D11 | 51
7 MISO | Yellow | D12 | 50
8 IRQ | NC | NC | NC
*/

/*
Controls:
10k pot wiper on A0, between VCC and GND
10k pot wiper on A0, between VCC and GND
NO Momentary Switch D2 to GND
NO Momentary Switch D3 to GND
*/

deviceMap deviceMapping[24] = {
{24, 0, 11, "L1 No.1 end white marker lights"},
{25, 1, 12, "L1 No.1 end Headlights"},
{26, 2, 13, "L1 No.2 end red marker lights"},
{27, 3, 14, "L1 No.2 end white marker lights"},
{28, 4, 15, "L1 No.2 end Headlights"},
{29, 5, 16, "L1 No.1 end red marker lights"},
{30, 6, 17, "L1 Horn"},
{31, 7, 18, "L1 Spare"},
{32, 8, 21, "L2 No.2 end white marker lights"},
{33, 9, 22, "L2 No.2 end Headlights"},
{34, 10, 23, "L2 No.2 end red marker lights"},
{35, 11, 24, "L2 No.1 end white marker lights"},
{36, 12, 25, "L2 No.1 end Headlights"},
{37, 13, 26, "L2 No.1 end red marker lights"},
{38, 14, 27, "L2 Horn"},
{39, 15, 28, "L2 Spare"},
{40, 16, 31, "L3 No.2 end white marker lights"},
{41, 17, 32, "L3 No.2 end Headlights"},
{42, 18, 33, "L3 No.2 end red marker lights"},
{43, 19, 34, "L3 No.1 end white marker lights"},
{44, 20, 35, "L3 No.1 end Headlights"},
{45, 21, 36, "L3 No.1 end red marker lights"},
{46, 22, 37, "L3 Horn"},
{47, 23, 38, "L3 Spare"},
};

const uint8_t numSlaves = 3;
RF24 radio(8, 53); // using pin 8 for the CE pin, and pin 53 for the CSN pin

uint8_t slaves[numSlaves][3] = {"L0002", "L0003", "L0004"};
uint8_t master[5] = "L0001";

controlMessage data = {0, 180, 0, 0b00000000000000000000000000000000};

unsigned long currentMillis;
unsigned long txMillis;
unsigned long txIntervalMillis = 100;

void setup() {
Serial.begin(9600);
// Some boards need to wait to ensure access to serial over USB
while (!Serial) {}

pinMode(A0,INPUT); // Throttle pot
pinMode(A1,INPUT); // Brake
pinMode(A2,INPUT); // Reverser

setupSwitchPins();

// Initialize the transceiver on the SPI bus
if (!radio.begin()) {
Serial.println(F("Radio hardware is not responding. Try resetting."));
while (1) {}
}
radio.setPALevel(RF24_PA_LOW);
radio.setChannel(124);
radio.setDataRate(RF24_250KBPS);
radio.setPayloadSize(sizeof(data));
radio.stopListening();
radio.openWritingPipe(slaves[0]);

Serial.println(F("TX setup() done. Starting main loop."));
delay(1000);
}

void loop()
{
currentMillis = millis();
if (currentMillis - txMillis >= txIntervalMillis) {
updateRelayData();
prettyPrintControlMessage();
send();
txMillis = millis();
}
}

void send()
{
unsigned long start_timer = micros();
bool report = radio.write(&data, sizeof(data));
unsigned long end_timer = micros();
if (report) {
Serial.println(F("Transmission successful!"));
} else {
Serial.println(F("Transmission failed or timed out"));
}
Serial.print(F("Time to transmit = "));
Serial.print(end_timer - start_timer);
Serial.println(F(" us."));
}

void updateRelayData()
{
data.throttle = map(analogRead(A0), 0, 1023, 0, 180);
data.brake = map(analogRead(A1), 0, 1023, 180, 0);
data.reverser = map(analogRead(A2), 0, 1023, 0, 180);
for (int i = 0; i < sizeof(deviceMapping) / sizeof(deviceMapping[0]); i++)
{
// Inverted logic for pulled up digital inputs.
if (digitalRead(deviceMapping[i].pin) == LOW) {
data.relays &= ~(1UL << deviceMapping[i].dataIdx);
} else {
data.relays |= 1UL << deviceMapping[i].dataIdx;
}
}
}

void setupSwitchPins()
{
for (int i = 0; i < sizeof(deviceMapping) / sizeof(deviceMapping[28]); i++)
{
pinMode(deviceMapping[i].pin, INPUT_PULLUP);
}
}

// Same functions below here.

void prettyPrintRelayData(uint8_t dataIdx)
{
deviceMap tmpMap;
Serial.print(F("D"));
if (dataIdx < 10)
{
Serial.print(F("0"));
}
Serial.print(dataIdx);
Serial.print(": ");
if ((data.relays >> dataIdx) & 1U)
{
Serial.print(F("ON "));
}
else
{
Serial.print(F("OFF "));
}
if (getMapByDataIdx(dataIdx, &tmpMap)) {
Serial.print(F("SW"));
if (tmpMap.deviceIdx < 10)
{
Serial.print(F("0"));
}
Serial.print(tmpMap.deviceIdx);
Serial.print(F(" "));
Serial.print(tmpMap.deviceName);
charRepeat(' ', sizeof(tmpMap.deviceName) - strlen(tmpMap.deviceName));
Serial.print(F(" "));
} else {
charRepeat(' ', 5 + sizeof(tmpMap.deviceName) + 1);
}
}

void prettyPrintControlMessage()
{
Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command
Serial.println(F("----------"));
Serial.print(F("Throttle: "));
Serial.println(data.throttle);
Serial.print(F("Brake: "));
Serial.println(data.brake);
Serial.print(F("Reverser: "));
Serial.println(data.reverser);
Serial.println(F("----------"));
// data.relays is a 32 bit unsigned int.
for (uint8_t r = 0; r < sizeof(data.relays) * 6; r++)
{
for (uint8_t c = 0; c < 2; c++)
{
prettyPrintRelayData(r + (c * 0));
}
Serial.println();
}
Serial.println(F("----------"));
}

bool getMapByDataIdx(uint8_t dataIdx, deviceMap* mapping)
{
for (int i = 0; i < sizeof(deviceMapping) / sizeof(deviceMapping[0]); i++)
{
if (deviceMapping[i].dataIdx == dataIdx) {
*mapping = deviceMapping[i];
return true;
}
}
return false;
}

void charRepeat(char character, uint8_t charcount)
{
for (int i = 0; i <= charcount; i++)
{
Serial.print(character);
}
}

 

And this is the Arduino sketch for one of the Slaves:-

#include <SPI.h>
#include "printf.h"
#include "RF24.h"
#include "Servo.h"

Servo throttle; //Throttle
Servo brake; //Brake
Servo reverser; //Reverser

struct deviceMap
{
// ---- mapping
uint8_t pin; // Physical pin
uint8_t dataIdx; // This is also used to map the bit in the data.relays
// ---- display only
uint8_t deviceIdx; // This is the "friendly" number e.g. 22 to match your mappings
char deviceName[33]; // Name for display
};

struct controlMessage
{
uint8_t throttle;
uint8_t brake;
uint8_t reverser;
uint32_t relays;
};

/*
nrf24l01+ Seed Modules:
NRF | Jumper | Arduino Nano | Arduino Mega
1 GND | Black | GND | GND
2 VCC | White | 3V3 | 3V3
3 CE | Grey | D7 | 8
4 CSN | Purple | D8 | 53
5 SCK | Blue | D13 | 52
6 MOSI | Green | D11 | 51
7 MISO | Yellow | D12 | 50
8 IRQ | NC | NC | NC
*/

/*
Outputs:
LED D2 to GND via 120R
LED D3 to GND via 120R
*/

deviceMap deviceMapping[8] = {
{24, 0, 11, "L1 No.1 end white marker lights"},
{25, 1, 12, "L1 No.1 end Headlights"},
{26, 2, 13, "L1 No.2 end red marker lights"},
{27, 3, 14, "L1 No.2 end white marker lights"},
{28, 4, 15, "L1 No.2 end Headlights"},
{29, 5, 16, "L1 No.1 end red marker lights"},
{30, 6, 17, "L1 Horn"},
{31, 7, 18, "L1 Spare"},
};

// instantiate an object for the nRF24L01 transceiver
RF24 radio(8, 53); // using pin 7 for the CE pin, and pin 53 for the CSN pin

uint8_t master[5] = "L0001";
uint8_t address[5] = "L0002";

controlMessage data = {0, 180, 0, B0};
controlMessage newData = {0, 180, 0, B0};

// Go to this if comms are lost.
controlMessage safeData = {0, 120, 0, B0};

unsigned long currentMillis = 0;
unsigned long controlMillis = 0;
unsigned long controlIntervalMillis = 100;
unsigned long lastReceiveMillis = 0;
unsigned long lastReceiveCautionMillis = 2000;
unsigned long lastReceivePanicMillis = 10000;

bool lastReceiveCaution = false;

void setup() {
Serial.begin(9600);
// Some boards need to wait to ensure access to serial over USB
while (!Serial) {}

setupRelayPins();

// Initialize the transceiver on the SPI bus
if (!radio.begin()) {
Serial.println(F("Radio hardware is not responding. Try resetting."));
while (1) {}
}
radio.setPALevel(RF24_PA_LOW);
radio.setChannel(124);
radio.setDataRate(RF24_250KBPS);
radio.setPayloadSize(sizeof(data));
radio.startListening();
radio.openReadingPipe(1, address);

Serial.println(F("RX setup() done. Starting main loop."));
delay(1000);
throttle.attach(2);
brake.attach(3);
reverser.attach(4);
}

void loop() {
// It can update newData as fast as it gets the data.
if (radio.available()) {
radio.read(&newData, sizeof(newData));
lastReceiveMillis = millis();
Serial.println("RX!");
lastReceiveCaution = false;
}
currentMillis = millis();
// Only mess with servos and relays every <controlIntervalMillis>ms
if (!lastReceiveCaution && (currentMillis - controlMillis >= controlIntervalMillis)) {
prettyPrintControlMessage();
updateServos();
updateRelays();
data = newData;
controlMillis = millis();
}

// Go to a safe mode when comms are lost for <lastReceiveCautionMillis>ms
if (!lastReceiveCaution && (currentMillis - lastReceiveMillis >= lastReceiveCautionMillis)) {
lastReceiveCaution = true;
goSafe();
// Try a radio reset?
}

// Stop all operations when comms are lost for <lastReceivePanicMillis>ms
if (lastReceiveCaution && (currentMillis - lastReceiveMillis >= lastReceivePanicMillis)) {
haltAndCatchFire();
}
}

void updateServos()
{
uint8_t servoPos = 0;
if (data.throttle != newData.throttle) {
servoPos = map(newData.throttle, 255 , 0, 0, 90);
throttle.write(servoPos);
}
if (data.brake != newData.brake) {
servoPos = map(newData.brake, 0, 255, 0, 120);
brake.write(servoPos);
}
if (data.reverser != newData.reverser) {
servoPos = map(newData.reverser, 0, 255, 0, 60);
reverser.write(servoPos);
}
}

void updateRelays()
{
deviceMap tmpMap;
for (int i = 0; i < sizeof(data.relays) * 8; i++)
{
// If it's not mapped, don't bother doing anything.
if (!getMapByDataIdx(i, &tmpMap)) {
continue;
}
uint8_t oldVal = (data.relays >> i) & 1U;
uint8_t newVal = (newData.relays >> i) & 1U;
if (oldVal != newVal)
{
digitalWrite(tmpMap.pin, newVal);
}
}
}

void setupRelayPins()
{
for (int i = 0; i < sizeof(deviceMapping) / sizeof(deviceMapping[0]); i++)
{
pinMode(deviceMapping[i].pin, OUTPUT);
}
}

// Same functions below here.

void prettyPrintRelayData(uint8_t dataIdx)
{
deviceMap tmpMap;
Serial.print(F("D"));
if (dataIdx < 10)
{
Serial.print(F("0"));
}
Serial.print(dataIdx);
Serial.print(": ");
if ((data.relays >> dataIdx) & 1U)
{
Serial.print(F("ON "));
}
else
{
Serial.print(F("OFF "));
}
// If it's not mapped, don't do anything.
if (getMapByDataIdx(dataIdx, &tmpMap)) {
Serial.print(F("RL"));
if (tmpMap.deviceIdx < 10)
{
Serial.print(F("0"));
}
Serial.print(tmpMap.deviceIdx);
Serial.print(F(" "));
Serial.print(tmpMap.deviceName);
charRepeat(' ', sizeof(tmpMap.deviceName) - strlen(tmpMap.deviceName));
Serial.print(F(" "));
} else {
charRepeat(' ', 5 + sizeof(tmpMap.deviceName) + 1);
}
}

void prettyPrintControlMessage()
{
Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command
Serial.println(F("----------"));
Serial.print(F("Throttle: "));
Serial.println(data.throttle);
Serial.print(F("Brake: "));
Serial.println(data.brake);
Serial.print(F("Reverser: "));
Serial.println(data.reverser);
Serial.println(F("----------"));
// data.relays is a 32 bit unsigned int.
for (uint8_t r = 0; r < sizeof(data.relays) * 4; r++)
{
for (uint8_t c = 0; c < 2; c++)
{
prettyPrintRelayData(r + (c * 8));
}
Serial.println();
}
Serial.println(F("----------"));
}

bool getMapByDataIdx(uint8_t dataIdx, deviceMap* mapping)
{
for (int i = 0; i < sizeof(deviceMapping) / sizeof(deviceMapping[0]); i++)
{
if (deviceMapping[i].dataIdx == dataIdx) {
*mapping = deviceMapping[i];
return true;
}
}
return false;
}

void charRepeat(char character, uint8_t charcount)
{
for (int i = 0; i <= charcount; i++)
{
Serial.print(character);
}
}

void goSafe()
{
Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command
Serial.print(F("No radio RX for "));
Serial.print(lastReceiveCautionMillis);
Serial.println("ms.");
Serial.println("Going safe.");
newData = safeData;
updateServos();
updateRelays();
}

void haltAndCatchFire()
{
Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command
Serial.print(F("No radio RX for "));
Serial.print(lastReceivePanicMillis);
Serial.println("ms.");
Serial.println("Halted.");
while (1) {}
}

 

Your help is most appreciated.


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea You might start at https://forum.arduino.cc/t/need-to-understand-serial-rs485-master-slave-addressing/65032/17

Also, look at the help on the top right and learn how to post code.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1725
 

Hi @waynea,

   In addition to the wise words from Ron @zander, please bear in mind that only you can see your system, and hence anyone trying to assist must rely on their imagination.

Hence, it is helpful to clearly describe what you expect the programme to do, and then explain what it actually does instead, together with any helpful other information, such as tests you have done to try to resolve the situation.

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea I did a little more searching and found GOLD. Nick Gammon is almost a god in the Arduino world and he shares his code, so here is a link to his post on RS485. This is as good as it gets, enjoy.

https://www.gammon.com.au/forum/?id=11428

BTW, in that post is the link to the protocol description.

I also found the ArduinoRS485 library page at https://www.arduino.cc/reference/en/libraries/arduinors485/

I also found the following link for Arduino boards built for RS485 specifically https://docs.arduino.cc/tutorials/opta/getting-started-with-rs485/

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@davee Do you think they will ever discover our 'secret weapon'?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@waynea)
Member
Joined: 2 years ago
Posts: 6
Topic starter  

Thank you for your help with the problem.

the current set up is a 2.4 GHz wireless system that works at home, but when I go to the clubs track the system occasionally works or plays up.  When the system plays up, the servo motors go from one end of their range then to the other.  They just keep go this plus the relays keep operating causing the lights to flash on and off with the horns blowing.   It appears that the radios are turning on and off, cycling.  Have used differently channels, addressing and power levels.  The on board arduino mega and NRF24L01 boards are supplied from a lead acid battery thru individual voltage regulators for either 5 or 3.3 volts.

The hand piece has 2 potentiometers, one for throttle and the other for the brake.  Then there is a 3 position switch for the Forward/Neutral/Reverse.  Then a set of switches for control of the lights and horns of the 3 locomotives.  The switches for the lights provide the Hi\Low for the logics.  The switches are of a type On/Off/On so enable lights at one end or the other.  Horn switches are just momentarily type.

Each locomotive has its own slave board, so any combination of the locomotives can be used, one, two or all 3 at one time.

Hoping this provides a bit off clarity on the system.

Also, normally the operator is within a few yards/metres of the locomotives.  This is to comply with regulations/ operating practices.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea Sorry, that is not very helpful at all, and is not a logical follow up to your original post. You originally said you were looking for assistance in learning about RS485. I replied with some information, I had to guess at what would be helpful given the lack of information.

I have NOT looked at your code at all as it is not properly displayed. Look at the HELP on how to do that, but I doubt the code is relevant to the RS485 query.

Just guessing, but is what you want just a simple conversion from NRF24L01 to RS485?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@waynea)
Member
Joined: 2 years ago
Posts: 6
Topic starter  

Hi,

I have a master a slave working using RS485 communication.

sorry I missed about the logic, as I though it was a simple remote control system.

the only logic that I had built into it was if the radio failed, the throttle servo was returned “Off” and the brake servo was set to “Full On”.  All other functions were to remain unchanged.

i was hoping I could find an example or some information on a simple conversion or the code.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea Ok, so you are using RS485. Why did you not show us that code?

I have no idea what the following means

sorry I missed about the logic, as I though it was a simple remote control system.

So I now understand that the following is what you need

i was hoping I could find an example or some information on a simple conversion or the code.

example of what?

conversion from what to what?

the code????

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea I was just reviewing the links I already sent you. Maybe if you would tell us why each of those links is NOT helpfull, I might be able to be of greater assistance.

Here are the links to the posts I am referencing 

https://forum.dronebotworkshop.com/postid/47449/

https://forum.dronebotworkshop.com/postid/47451/

I think your best bet is to use Nick's libraries. 

I took a fairly quick look at your code and Nicks, and it looks like a fairly simple conversion.

Good luck.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@waynea)
Member
Joined: 2 years ago
Posts: 6
Topic starter  

Hi, the links were all helpful in there way.  With the links I got the 2 arduino mega boards communicating with each other but I got totally confused in how to re-write the code.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea Not a re-write, it is a few lines that need to be changed.

First install the following library https://github.com/nickgammon/RS485_protocol or the non-blocking version at https://github.com/nickgammon/RS485_non_blocking

Now simply follow Nicks instructions re callbacks etc at https://www.gammon.com.au/forum/?id=11428

For example, in your master sketch replace the line (blocking ver)

bool report = radio.write(&data, sizeof(data));
 
Here are a couple screen grabs from Nicks page on this. READ ALL of it as there are some gotchas.
Screenshot 2024 05 07 at 07.02.09
Screenshot 2024 05 07 at 07.02.20

For all the information, see https://www.gammon.com.au/forum/?id=11428

Good luck.

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea Are you on your way now? I plan on stepping away from the forum but want to close any outstanding issues.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@waynea)
Member
Joined: 2 years ago
Posts: 6
Topic starter  

I’m on my way slowly.  In reading through Nickgammon code example, there is mention of pot on pin A0 but reading the example in loop function it reads …. analog read (0) / 4;  is this just a typo and should read A0?


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@waynea It would appear so. Best to use the supplied pin definitions. UNIQUE per board. Here is the UNO definitions in pins_arduino.h

Screenshot 2024 05 13 at 07.25.02

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote