Go to file
2026-03-10 17:02:11 +01:00
includes dev 2026-03-10 17:02:11 +01:00
src dev 2026-03-10 17:02:11 +01:00
unused initial commit 2026-03-09 15:08:40 +01:00
.gitignore initial commit 2026-03-09 15:08:40 +01:00
LICENSE add license 2026-03-09 15:12:35 +01:00
Makefile initial commit 2026-03-09 15:08:40 +01:00
README.md dev 2026-03-10 16:02:53 +01:00

fdr1-modbus-slave

Firmware Modbus RTU esclave pour trancanneur industriel, conçu pour tourner sur la carte FDR1 v1.00.

Le PIC lit la vitesse du fil via le périphérique QEI, pilote le moteur de bobine (SPOOL) et synchronise le guide-fil (ARM) via un virtual gear configurable. La communication avec le maître (OpenPLC ou autre) se fait en Modbus RTU RS232/RS485.


Matériel requis

  • Carte FDR1 v1.00
  • Microcontrôleur PIC18F4431
  • Quartz 8 MHz (HSPLL x4 → Fosc = 32 MHz)
  • Encodeur incrémental raccordé au périphérique QEI
  • 2 drivers pas à pas Step/Dir (SPOOL + ARM)
  • Liaison série RS232 (RS485 à venir)

Configuration Modbus RTU

Paramètre Valeur
Adresse esclave 183
Vitesse 115200 bps
Format 8N1
Function codes FC03, FC06, FC16

Registres Modbus

Lecture (FC03)

Adresse Nom Type Description
0x1700 QEI_POS UINT16 Vitesse fil (position QEI)

Écriture (FC06 / FC16)

Adresse Nom Type Accès Description
0x0800 REG_CTRL UINT16 R/W Registre de contrôle (voir bits ci-dessous)
0x0801 SPOOL_FREQ UINT16 R/W Fréquence moteur SPOOL (Hz, 0=arrêt)
0x0802 ARM_GEAR UINT16 R/W Virtual gear ARM (µm par tour SPOOL, 0=arrêt)
0x0803 ARM_OFFSET UINT16 R/W Distance capteur home → origine (µm) — EEPROM
0x0804 ARM_LEFT UINT16 R/W Position limite gauche (1/10 mm, défaut: 500)
0x0805 ARM_RIGHT UINT16 R/W Position limite droite (1/10 mm, défaut: 4500)
0x0806 SPOOL_RATIO UINT16 R/W Démultiplication SPOOL (millièmes, 1000=1:1) — EEPROM

Bits REG_CTRL (0x0800)

Bit Nom Description
15 SPOOL_ENABLE Active le moteur SPOOL
14 SPOOL_DIR Sens de rotation SPOOL
13 ARM_HOMING Lance la procédure de prise d'origine (one-shot)
12 ARM_GO_TO_ZERO Retour ARM à LEFT, démarre nouveau cycle (one-shot)
1 ARM_FREE Libère le moteur ARM (désactive vgear + ENABLE=0)

EEPROM interne

Adresse Contenu
0x10 ARM_OFFSET high
0x11 ARM_OFFSET low
0x12 SPOOL_RATIO high
0x13 SPOOL_RATIO low

Fonctionnement normal

En production, seuls deux registres sont utilisés en continu :

FC03 0x1700  → lecture vitesse fil
FC06 0x0801  → consigne vitesse SPOOL

Les registres de configuration (0x0802~0x0806) sont écrits une fois à la mise en service.


Build & Flash

Prérequis

  • XC8 (dans le PATH)
  • MPLABX v6.20 avec DFP PIC18Fxxxx installé
  • PICkit3

Compilation

make

Flashage

make flash

Nettoyage

make clean

Licence

Copyright (c) 2026, FDR1 Project
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the FDR1 Project.
  4. Neither the name of the FDR1 Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.