Skip to content

Commit

Permalink
on -4ssssssssssssssssssssss
Browse files Browse the repository at this point in the history
  • Loading branch information
lukestroh committed Sep 26, 2024
2 parents 10e8cc1 + 13a40ad commit 3d4e31d
Show file tree
Hide file tree
Showing 13 changed files with 777 additions and 103 deletions.
Binary file modified .vs/ClearCoreVelocityController/v14/.atsuo
Binary file not shown.
6 changes: 0 additions & 6 deletions ClearCoreVelocityController.atsln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{E66E83B9-2572-4076-B26E-6BE79FF3018A}") = "ClearCore", "..\libClearCor
EndProject
Project("{E66E83B9-2572-4076-B26E-6BE79FF3018A}") = "LwIP", "..\LwIP\LwIP.cppproj", "{C373696C-5D45-4B91-AD62-A21552361596}"
EndProject
Project("{E66E83B9-2572-4076-B26E-6BE79FF3018A}") = "ManualVelocity", "..\..\..\..\..\..\Program Files (x86)\Teknic\ClearCore-Library 1.0\Microchip_Examples\ClearPathModeExamples\ClearPath-MC_Series\ManualVelocity\ManualVelocity.cppproj", "{8E27B935-12EA-4FA1-8A5F-53EB06696B1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Expand All @@ -29,10 +27,6 @@ Global
{C373696C-5D45-4B91-AD62-A21552361596}.Debug|ARM.Build.0 = Debug|ARM
{C373696C-5D45-4B91-AD62-A21552361596}.Release|ARM.ActiveCfg = Release|ARM
{C373696C-5D45-4B91-AD62-A21552361596}.Release|ARM.Build.0 = Release|ARM
{8E27B935-12EA-4FA1-8A5F-53EB06696B1A}.Debug|ARM.ActiveCfg = Debug|ARM
{8E27B935-12EA-4FA1-8A5F-53EB06696B1A}.Debug|ARM.Build.0 = Debug|ARM
{8E27B935-12EA-4FA1-8A5F-53EB06696B1A}.Release|ARM.ActiveCfg = Release|ARM
{8E27B935-12EA-4FA1-8A5F-53EB06696B1A}.Release|ARM.Build.0 = Release|ARM
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions ClearCoreVelocityController.cppproj
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@
<Compile Include="Device_Startup\startup_same53.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="include\interrupts.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="include\system.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\ClearPathMC.cpp">
<SubType>compile</SubType>
</Compile>
Expand Down
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,52 @@
# ProjectTemplate

This repository contains a basic ClearCore project that can be used as a template for new application development.
Place this repository rooted in the same parent directory as libClearCore and LwIP to properly find include files and libraries.
Place this repository rooted in the same parent directory as libClearCore and LwIP to properly find include files and libraries.

## Requirements:

### ETHERNET COMMUNICATION:
1. The PC should be running software capable of sending and receiving UDP
packets. See `udp_client.py` for simple testing.


### MOTOR:
1. A ClearPath motor must be connected to Connector M-0.
2. The connected ClearPath motor must be configured through the MSP software
for Manual Velocity Control mode (In MSP select Mode>>Velocity>>Manual
Velocity Control, then hit the OK button).
3. In the MSP software:
Define a Max Clockwise and Counter-Clockwise (CW/CCW) Velocity (On the
main MSP window fill in the textboxes labeled "Max CW Velocity (RPM)"
and "Max CCW Velocity (RPM)"). Any velocity commanded outside of this
range will be rejected.
Set the Velocity Resolution to 2 (On the main MSP window check the
textbox labeled "Velocity Resolution (RPM per knob count)" 2 is
default). This means the commanded velocity will always be a multiple
of 2. For finer resolution, lower this value and change
velocityResolution in the sketch below to match.
Set Knob Direction to As-Wired, and check the Has Detents box (On the
main MSP window check the dropdown labeled "Knob Direction" and the
checkbox directly below it labeled "Has Detents").
On the main MSP window set the dropdown labeled "On Enable..." to be
"Zero Velocity".
Set the HLFB mode to "ASG-Velocity w/Measured Torque" with a PWM carrier
frequency of 482 Hz through the MSP software (select Advanced>>High
Level Feedback \[Mode\]... then choose "ASG-Velocity w/Measured Torque"
from the dropdown, make sure that 482 Hz is selected in the "PWM Carrier
Frequency" dropdown, and hit the OK button).

### LIMIT SWITCHES:
1. Negative and Positive Limit switches should be connected to the DI-7 and DI-8 inputs on the controller, respectively.


### EMERGENCY STOP:
1. Emergency stop should be connected to the DI-6 input on the controller.

Links:
ClearCore Documentation: https://teknic-inc.github.io/ClearCore-library/
ClearCore Manual: https://www.teknic.com/files/downloads/clearcore_user_manual.pdf


Copyright (c) 2020 Teknic Inc. This work is free to use, copy and distribute under the terms of
the standard MIT permissive software license which can be found at https://opensource.org/licenses/MIT
167 changes: 167 additions & 0 deletions Release/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

SHELL := cmd.exe
RM := rm -rf

USER_OBJS :=

LIBS :=
PROJ :=

O_SRCS :=
C_SRCS :=
S_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
PREPROCESSING_SRCS :=
OBJS :=
OBJS_AS_ARGS :=
C_DEPS :=
C_DEPS_AS_ARGS :=
EXECUTABLES :=
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=

# Every subdirectory with source files must be described here
SUBDIRS := \
../Device_Startup/ \
../include \
../src


# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../Device_Startup/startup_same53.c \
../src/ClearPathMC.cpp \
../src/EthUDP.cpp \
../main.cpp


PREPROCESSING_SRCS +=


ASM_SRCS +=


OBJS += \
Device_Startup/startup_same53.o \
src/ClearPathMC.o \
src/EthUDP.o \
main.o

OBJS_AS_ARGS += \
Device_Startup/startup_same53.o \
src/ClearPathMC.o \
src/EthUDP.o \
main.o

C_DEPS += \
Device_Startup/startup_same53.d \
src/ClearPathMC.d \
src/EthUDP.d \
main.d

C_DEPS_AS_ARGS += \
Device_Startup/startup_same53.d \
src/ClearPathMC.d \
src/EthUDP.d \
main.d

OUTPUT_FILE_PATH +=ClearCoreVelocityController.elf

OUTPUT_FILE_PATH_AS_ARGS +=ClearCoreVelocityController.elf

ADDITIONAL_DEPENDENCIES:=

OUTPUT_FILE_DEP:= ./makedep.mk

LIB_DEP+= \
C:/Users/lukes/Documents/Atmel\ Studio/7.0/libClearCore/Release/libClearCore.a \
C:/Users/lukes/Documents/Atmel\ Studio/7.0/LwIP/Release/libLwIP.a

LINKER_SCRIPT_DEP+= \
../Device_Startup/flash_with_bootloader.ld \
../Device_Startup/flash_without_bootloader.ld


# AVR32/GNU C Compiler
Device_Startup/startup_same53.o: ../Device_Startup/startup_same53.c
@echo Building file: $<
@echo Invoking: ARM/GNU C Compiler : 6.3.1
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe$(QUOTE) -x c -mthumb -D__SAME53N19A__ -DNDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\SAME53_DFP\1.1.118\include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\4.5.0\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\5.4.0\CMSIS\Core\Include" -O3 -ffunction-sections -fdata-sections -Wall -mcpu=cortex-m4 -c -std=gnu11 --param max-inline-insns-single=50 -MMD -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<


src/ClearPathMC.o: ../src/ClearPathMC.cpp
@echo Building file: $<
@echo Invoking: ARM/GNU C Compiler : 6.3.1
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-g++.exe$(QUOTE) -mthumb -D__SAME53N19A__ -DNDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\4.5.0\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\SAME53_DFP\1.1.118\include" -I"../../libClearCore/inc" -I"../../LwIP/LwIP/src/include" -I"../../LwIP/LwIP/port/include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\5.4.0\CMSIS\Core\Include" -O3 -ffunction-sections -fno-rtti -fno-exceptions -Wall -mcpu=cortex-m4 -c -std=gnu++11 -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -MMD -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<


src/EthUDP.o: ../src/EthUDP.cpp
@echo Building file: $<
@echo Invoking: ARM/GNU C Compiler : 6.3.1
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-g++.exe$(QUOTE) -mthumb -D__SAME53N19A__ -DNDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\4.5.0\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\SAME53_DFP\1.1.118\include" -I"../../libClearCore/inc" -I"../../LwIP/LwIP/src/include" -I"../../LwIP/LwIP/port/include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\5.4.0\CMSIS\Core\Include" -O3 -ffunction-sections -fno-rtti -fno-exceptions -Wall -mcpu=cortex-m4 -c -std=gnu++11 -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -MMD -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<


./main.o: .././main.cpp
@echo Building file: $<
@echo Invoking: ARM/GNU C Compiler : 6.3.1
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-g++.exe$(QUOTE) -mthumb -D__SAME53N19A__ -DNDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\4.5.0\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\SAME53_DFP\1.1.118\include" -I"../../libClearCore/inc" -I"../../LwIP/LwIP/src/include" -I"../../LwIP/LwIP/port/include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\5.4.0\CMSIS\Core\Include" -O3 -ffunction-sections -fno-rtti -fno-exceptions -Wall -mcpu=cortex-m4 -c -std=gnu++11 -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -MMD -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<





# AVR32/GNU Preprocessing Assembler



# AVR32/GNU Assembler




ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

# Add inputs and outputs from these tool invocations to the build variables

# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)

$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
@echo Building target: $@
@echo Invoking: ARM/GNU Linker : 6.3.1
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-g++.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -mthumb -Wl,-Map="ClearCoreVelocityController.map" --specs=rdimon.specs -Wl,--start-group -lm -larm_cortexM4lf_math -lClearCore -lLwIP -Wl,--end-group -L"..\\Device_Startup" -L"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\CMSIS\4.5.0\CMSIS\Lib\GCC" -L"C:\Users\lukes\Documents\Atmel Studio\7.0\libClearCore\Release" -L"C:\Users\lukes\Documents\Atmel Studio\7.0\LwIP\Release" -Wl,--gc-sections -mcpu=cortex-m4 -Tsame53n19a_flash.ld -mfloat-abi=hard -mfpu=fpv4-sp-d16
@echo Finished building target: $@
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-objcopy.exe" -O binary "ClearCoreVelocityController.elf" "ClearCoreVelocityController.bin"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-size.exe" "ClearCoreVelocityController.elf"







# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "ClearCoreVelocityController.elf" "ClearCoreVelocityController.a" "ClearCoreVelocityController.hex" "ClearCoreVelocityController.bin" "ClearCoreVelocityController.lss" "ClearCoreVelocityController.eep" "ClearCoreVelocityController.map" "ClearCoreVelocityController.srec"

12 changes: 12 additions & 0 deletions Release/makedep.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################

Device_Startup\startup_same53.c

src\ClearPathMC.cpp

src\EthUDP.cpp

main.cpp

54 changes: 38 additions & 16 deletions include/EthUDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,63 @@
*/
#include "ClearCore.h"
#include "EthernetUdp.h"
#include "system.h"

#ifndef ETHUDP_H_
#define ETHUDP_H_

#ifndef __ETHUDP_DEBUG__
#define __ETHUDP_DEBUG__ 0
#endif

class EthUDP {
private:
// Local IP address, port
IpAddress local_ip;
const int local_port;
IpAddress m_local_ip;
const int m_local_port;

// Host IP address, port
IpAddress remote_ip = IpAddress(169, 254, 93, 234);
const int remote_port = 8888;
IpAddress m_remote_ip;
const int m_remote_port;

// Read data attributes
char* m_token;
const char* m_delimiter = ",";
bool m_using_dhcp = false;
const uint8_t MAX_PACKET_LENGTH = 128; // Maximum number of characters to receive from an incoming packet

// Send data attributes
char m_status_buf[2];
char m_data_buf[10];
const char* m_msg_status_header = "{\"status\":";
const char* m_msg_data_header = "\"servo_rpm\":";
const char* m_msg_footer = "}";

// Data buffers
unsigned char m_received_packet[128]; // Buffer for holding received packets
char m_msg_buf[128]; // Send message buffer

public:
// Data buffer
// New data flag
bool new_data = false;
bool using_dhcp = false;
const uint8_t MAX_PACKET_LENGTH = 128; // Maximum number of characters to receive from an incoming packet
unsigned char received_packet[128]; // Buffer for holding received packets
char msg_buf[128];


// Ethernet UDP
EthernetUdp udp;

EthUDP();
EthUDP(IpAddress _ip);
EthUDP(IpAddress _ip, int _port);
~EthUDP();

EthUDP(IpAddress _local_ip);
EthUDP(IpAddress _local_ip, int _local_port);
EthUDP(IpAddress _local_ip, IpAddress _remote_ip);
EthUDP(IpAddress _local_ip, int _local_port, IpAddress _remote_ip, int _remote_port);
~EthUDP();

// Public methods
void begin();
void read_packet();
char* construct_data_msg(float data); // // Set true if using DHCP to configure the local IP address
void send_packet(float data);
void read_packet(slidersystem::DataInterface* command_interface);
void construct_data_msg(slidersystem::DataInterface* state);
void send_packet(slidersystem::DataInterface* state);

};

#endif /* ETHUDP_H_ */
Loading

0 comments on commit 3d4e31d

Please sign in to comment.