Compare commits

...

5 Commits

Author SHA1 Message Date
Miaow
ceb5469c17 docs: 修改README,添加version文件
1. README中添加了实物图片
2. 修正了README的目录结构章节
3. README中扩充了tag定义
4. README中添加了version文件的要求
5. 各目录下添加了version文件
6. 添加了doc
2023-02-05 22:10:16 +08:00
MIAOW
61bc985d5c
Merge pull request #1 from weiliang987644015/b01-pcandysorting-thardcandy1
add epc9600ioextend board
2022-06-13 16:05:47 +08:00
weiliang987644015
a6547e4184 add epc9600ioextend board 2022-06-13 16:02:47 +08:00
Miaow
d6e22519d5 fix bug at resuming operation
The START command following a STOP command can cause misplaced counters. This commit fixes the bug by setting counter variables to their initial value as soon as STOP command reaches.
2022-03-10 15:30:21 +08:00
miaow
657cdf2691 add hardware and script readme
Co-Authored-By: Suhandong <80463329+Suhandong@users.noreply.github.com>
2022-01-16 14:06:42 +08:00
18 changed files with 1236 additions and 55 deletions

BIN
README.assets/qwe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

View File

@ -1,10 +1,15 @@
# 下位机
下位机根据传送带脉冲等触发相机,接收上位机给的数据,按其要求控制阀板,用在各种分选机上。
糖果分选机的下位机根据传送带脉冲等触发相机,接收上位机给的数据,按其要求控制阀板,用在各种分选机上。本次下位机采用的硬件是[广州致远电子股份有限公司 ](https://www.zlg.cn/)(周立功)的[EPC-9600I-L工控主板](https://www.zlg.cn/ipc/ipc/product/id/77.html)简称EPC9600自带各种接口但是除了网口和DI/DO接口其他接口统统用不到。阀板接口、触发相机的接口、编码器接口都是连接自己做的IO扩展板将IO扩展板插在底板DI/DO接口上叠起来因此称为叠板。要注意IO扩展板上的供电接口仅仅用于IO扩展板自身的供电EPC9600的供电需要另外提供。
![qwe](README.assets/qwe.png)
图中左到右分别为EPC9600IO扩展板糖果分选机整机相机上位机编码器。其中相机的触发线、编码器连接到IO扩展板相机、上位机、EPC9600连接到以太网交换机。下面是接线图
![接线图待补充](README.assets/接线图.png)
## 目录结构
- binary为编译好的可执行文件
- script为配置系统、安装环境、安装可执行文件、卸载可执行文件等的脚本
- protocol为上位机和下位机通信的协议
- hardware下位机主板、接口板、底板等的硬件设计
@ -27,10 +32,10 @@ b分支编号-p生产环境项目名-t分选对象[-其他特点1[-其他特点2
版本号遵循定义如下(不使用中文,小写无空格)
```shell
b分支编号-n编译号-h硬件版本-p协议版本-s脚本版本-r代码版本
b分支编号[-d文档版本]-hPCB设计版本[-lFPGA设计版本]-p协议版本[-s脚本版本]-aAPP代码版本[-i驱动版本][-c系统编译配置版本][-e设备树版本]
```
分支编号和分支命名中编号一致
中括号在这里表示可省略的项,中括号本身不应出现在实际命名中。分支编号和分支命名中编号一致。各部分版本应在相应目录下创建文件注明,比如`2.1`版本的PCB设计PCB工程目录中建立`version`文本文件,内容为文本`2.1`。对于涉及整体设计的大改动版本号加`1`,其余改动版本号加`0.1`。每个分支的版本各自独立,新分支的版本从`1.0`起计算
## 作者

Binary file not shown.

0
doc/deploy.md Normal file
View File

View File

1
doc/version Normal file
View File

@ -0,0 +1 @@
0.1

BIN
hardware/asm/PCB1.PCBDwf Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
Record=TopLevelDocument|FileName=Sheet1.SchDoc|SheetNumber=1

BIN
hardware/lib/mw.PcbLib Normal file

Binary file not shown.

BIN
hardware/lib/mw.SchLib Normal file

Binary file not shown.

BIN
hardware/pcb/PCB1.PcbDoc Normal file

Binary file not shown.

BIN
hardware/sch/Sheet1.SchDoc Normal file

Binary file not shown.

1
hardware/version Normal file
View File

@ -0,0 +1 @@
1.0

1
protocol/version Normal file
View File

@ -0,0 +1 @@
1.0

1
script/version Normal file
View File

@ -0,0 +1 @@
0.1

View File

@ -12,11 +12,8 @@
*/
typedef enum
{
NOT_INITIALIZED = 0,
INITIALIZED = 1,
RUNNING = 2,
SLEEPING = 3,
STOPPED = 4
SLEEPING = 0,
RUNNING = 1,
} status_enum_t;
valvedata_t valvedata = {0};
@ -25,11 +22,11 @@ queue_uint64_msg_t cmd_queue = {0};
static int count_valve = 1, count_camera = 0, count_valve_should_be = 2;
static uint64_t count_continues = 0UL, count_valve_continues = 0UL, count_camera_continues = 0UL;
static status_enum_t status = NOT_INITIALIZED;
static int camera_trigger_pulse_count = 0;
static int valve_should_trigger_pulse_count = 0;
static int valve_trigger_pulse_count = 0;
static int camera_to_valve_pulse_count = 0;
static status_enum_t status = SLEEPING;
static int camera_trigger_pulse_count = 500;
static int valve_should_trigger_pulse_count = 1;
static int valve_trigger_pulse_count = 10;
static int camera_to_valve_pulse_count = 3015;
#define ROTATE_UINT64_RIGHT(x, n) ((x) >> (n)) | ((x) << ((64) - (n)))
#define ROTATE_UINT64_LEFT(x, n) ((x) << (n)) | ((x) >> ((64) - (n)))
@ -50,11 +47,15 @@ int main(int argc, char *argv[])
// fflush(stdout);
// valve_test3(100.0f);
// valve_test2(200.0f, 0);
// valve_test(200.0f);
// for (int i = 0; i < 999; i++)
// {
// valve_test(200.0f);
// }
// printf("OK\r\n");
// valve_deinit();
hostcomputer_init(&data_queue, &cmd_queue);
printf("\r\n>>>>>\r\nstatus==SLEEPING\r\n<<<<<\r\n\r\n");
uint64_t cmd;
int TRUE = 1;
while (TRUE)
@ -62,12 +63,25 @@ int main(int argc, char *argv[])
if (queue_uint64_get(&cmd_queue, &cmd) == 0)
{
process_cmd(&cmd);
usleep(100000);
}
usleep(100000);
}
hostcomputer_deinit();
queue_uint64_deinit(&data_queue);
queue_uint64_deinit(&cmd_queue);
// encoder_init(on_encoder);
// sleep(100);
// encoder_deinit();
// cameratrigger_init();
// for (int i = 0; i < 100; i++)
// {
// sleep(1);
// cameratrigger_trig();
// }
// cameratrigger_deinit();
return 0;
}
@ -79,14 +93,16 @@ void process_cmd(uint64_t *cmd)
{
if (tmp_cmd == HOSTCOMPUTER_CMD_START)
{
queue_uint64_clear(&data_queue);
valve_should_trigger_pulse_count = camera_trigger_pulse_count / HOST_COMPUTER_PICTURE_ROW_NUM;
for (int i = 0; i < camera_to_valve_pulse_count * HOST_COMPUTER_PICTURE_ROW_NUM / camera_trigger_pulse_count; i++)
queue_uint64_put(&data_queue, 0);
queue_uint64_put(&data_queue, 0L);
valve_init();
cameratrigger_init();
encoder_init(on_encoder);
printf("\r\n>>>>>\r\nstatus==RUNNING\r\ncamera_trigger_pulse_count=%d\r\nvalve_trigger_pulse_count=%d\r\ncamera_to_valve_pulse_count=%d\r\n<<<<<\r\n\r\n", camera_trigger_pulse_count, valve_trigger_pulse_count, camera_to_valve_pulse_count);
status = RUNNING;
printf("\r\n>>>>>\r\nstatus==RUNNING\r\n<<<<<\r\n\r\n");
}
else if (tmp_cmd == HOSTCOMPUTER_CMD_TEST)
{
@ -94,10 +110,7 @@ void process_cmd(uint64_t *cmd)
valve_test(500.0f);
valve_deinit();
}
}
else if (status == NOT_INITIALIZED)
{
if (tmp_cmd == HOSTCOMPUTER_CMD_SETCAMERATRIGPULSECOUNT)
else if (tmp_cmd == HOSTCOMPUTER_CMD_SETCAMERATRIGPULSECOUNT)
{
camera_trigger_pulse_count = tmp_data;
}
@ -109,38 +122,6 @@ void process_cmd(uint64_t *cmd)
{
camera_to_valve_pulse_count = tmp_data;
}
else if (tmp_cmd == HOSTCOMPUTER_CMD_TEST)
{
valve_init();
valve_test(500.0f);
valve_deinit();
}
if (camera_trigger_pulse_count != 0 && valve_trigger_pulse_count != 0 && camera_to_valve_pulse_count != 0)
{
status = INITIALIZED;
printf("\r\n>>>>>\r\nstatus==INITIALIZED\r\ncamera_trigger_pulse_count=%d\r\nvalve_trigger_pulse_count=%d\r\ncamera_to_valve_pulse_count=%d\r\n<<<<<\r\n\r\n", camera_trigger_pulse_count, valve_trigger_pulse_count, camera_to_valve_pulse_count);
}
}
else if (status == INITIALIZED)
{
if (tmp_cmd == HOSTCOMPUTER_CMD_START)
{
valve_should_trigger_pulse_count = camera_trigger_pulse_count / HOST_COMPUTER_PICTURE_ROW_NUM;
printf("valve_should_trigger_pulse_count=%d", valve_should_trigger_pulse_count);
for (int i = 0; i < camera_to_valve_pulse_count * HOST_COMPUTER_PICTURE_ROW_NUM / camera_trigger_pulse_count; i++)
queue_uint64_put(&data_queue, 0);
valve_init();
cameratrigger_init();
encoder_init(on_encoder);
status = RUNNING;
printf("\r\n>>>>>\r\nstatus==RUNNING\r\n<<<<<\r\n\r\n");
}
else if (tmp_cmd == HOSTCOMPUTER_CMD_TEST)
{
valve_init();
valve_test(500.0f);
valve_deinit();
}
}
else if (status == RUNNING)
{
@ -150,6 +131,12 @@ void process_cmd(uint64_t *cmd)
cameratrigger_deinit();
valve_deinit();
queue_uint64_clear(&data_queue);
count_continues = 0UL;
count_valve_continues = 0UL;
count_camera_continues = 0UL;
count_valve = 1;
count_camera = 0;
count_valve_should_be = 2;
status = SLEEPING;
printf("\r\n>>>>>\r\nstatus==SLEEPING\r\n<<<<<\r\n\r\n");
}
@ -159,6 +146,7 @@ void process_cmd(uint64_t *cmd)
void valve_test(float ms_for_each_channel)
{
uint64_t valve_data = 1ul;
for (int i = 0; i < 48; i++)
{
usleep((useconds_t)(ms_for_each_channel * 500.0f));
@ -220,7 +208,7 @@ void on_encoder()
// printf("data:%llx send to valve, queue length is %d\r\n", valvedata.valvedata_1, data_queue.nData);
// printf("%016llx ", valvedata.valvedata_1);
fflush(stdout);
// fflush(stdout);
}
if (++count_valve_should_be == valve_should_trigger_pulse_count + 2)

1
source/version Normal file
View File

@ -0,0 +1 @@
1.0