From a72933cf32e394f99cb023c521e13c443de4d25c Mon Sep 17 00:00:00 2001
From: Jake <jake.read@cba.mit.edu>
Date: Wed, 18 Jul 2018 16:41:39 +0200
Subject: [PATCH] update before closed loop comm

---
 circuit/README.md                                  |  1 +
 circuit/atkbldcdriver/atkbldcdriver.brd            |  2 +-
 circuit/atkbldcdriver/eagle.epf                    | 14 +++++++-------
 embedded/README.md                                 |  8 +++++++-
 .../atkbldcdriver/atkbldcdriver.cproj              |  4 ++--
 embedded/atkbldcdriver/atkbldcdriver/main.c        |  4 ++++
 6 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/circuit/README.md b/circuit/README.md
index a2f06f0..a57a871 100644
--- a/circuit/README.md
+++ b/circuit/README.md
@@ -13,6 +13,7 @@ Power is bussed to the board with two M3 Screw Terminals. The board includes roo
  - label lights 
  - wants one lo-side debug pin!
  - for resets etc, pull en to gnd on other side of switch!
+ - wants spi debug pins 
 
  - might have to go to DRV8320 - newer, available
   - CSD88548 is CSD88599 but more amps less volts, use these 
diff --git a/circuit/atkbldcdriver/atkbldcdriver.brd b/circuit/atkbldcdriver/atkbldcdriver.brd
index c71e034..0d0bc31 100644
--- a/circuit/atkbldcdriver/atkbldcdriver.brd
+++ b/circuit/atkbldcdriver/atkbldcdriver.brd
@@ -3622,7 +3622,7 @@ design rules under a new name.</description>
 <wire x1="54.7" y1="49.9378875" x2="52.8474875" y2="51.7904" width="0.1524" layer="1"/>
 <wire x1="52.8474875" y1="51.7904" x2="49.3904" y2="51.7904" width="0.1524" layer="1"/>
 <wire x1="49.3904" y1="51.7904" x2="49.15" y2="51.55" width="0.1524" layer="1"/>
-<wire x1="49.15" y1="51.55" x2="49.15" y2="51.1" width="0" layer="19" extent="1-1"/>
+<wire x1="49.15" y1="51.55" x2="49.15" y2="51.1" width="0.1524" layer="1"/>
 </signal>
 <signal name="PWMLOW">
 <contactref element="U1" pad="16"/>
diff --git a/circuit/atkbldcdriver/eagle.epf b/circuit/atkbldcdriver/eagle.epf
index 0ef4ef7..5db0460 100644
--- a/circuit/atkbldcdriver/eagle.epf
+++ b/circuit/atkbldcdriver/eagle.epf
@@ -1,5 +1,5 @@
 [Eagle]
-Version="09 01 01"
+Version="09 00 00"
 Platform="Windows"
 Globals="Globals"
 Desktop="Desktop"
@@ -42,7 +42,7 @@ UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/sparkfun/SparkFu
 Type="Board Editor"
 Number=1
 File="atkbldcdriver.brd"
-View="46.0222 19.7572 101.977 66.359"
+View="46.6255 23.8801 69.1125 42.6084"
 WireWidths=" 0.0762 0.127 0.15 0.508 0.6096 0.8128 2.54 1.016 1.27 0.3048 0.254 0.2 0.4064 0.1016 0.2032 0.1524"
 PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
 PadDrills=" 0.2 0.25 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6 0.3"
@@ -58,7 +58,7 @@ DimensionExtWidths=" 0.127 0.254 0.1 0.13 0.26 0"
 DimensionExtLengths=" 1.27 2.54 1 2 3 0"
 DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
 SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
-WireBend=1
+WireBend=3
 WireBendSet=0
 WireCap=1
 MiterStyle=0
@@ -84,9 +84,9 @@ Layer=1
 
 [Win_2]
 Type="Schematic Editor"
-Number=2
+Number=3
 File="atkbldcdriver.sch"
-View="-199.977 -15.3886 91.806 117.046"
+View="-280.35 -76.1712 223.851 152.676"
 WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
 PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
 PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
@@ -125,7 +125,7 @@ ArcDirection=0
 AddLevel=2
 PadsSameType=0
 Layer=91
-Views=" 1: -199.977 -15.3886 91.806 117.046"
+Views=" 1: -280.35 -76.1712 223.851 152.676"
 Sheet="1"
 
 [Win_3]
@@ -133,7 +133,7 @@ Type="Control Panel"
 Number=0
 
 [Desktop]
-Screen="3840 1080"
+Screen="1920 1080"
 Window="Win_1"
 Window="Win_2"
 Window="Win_3"
diff --git a/embedded/README.md b/embedded/README.md
index bd27525..7b6fd78 100644
--- a/embedded/README.md
+++ b/embedded/README.md
@@ -26,4 +26,10 @@ This worked out fairly well, I'll add some video ... I run one timer to commutat
 
 In any case, I'd say it's enough to start trying to cut things, with some more current available. Hopefully I won't fry anything in the process: hand on the e-stop!
 
-![video of olcomm](/video/atkbldc-openloop-com.mp4)
\ No newline at end of file
+![video of olcomm](/video/atkbldc-openloop-com.mp4)
+
+## Closing a loop on 6-Step Commutation
+
+I know I can do this if I can manage to read my encoder successfully. I could also probably do it with the ADC, but I would want an oscilloscope to go down that path, and I don't have one here.
+
+So, we use a logic analyzer to try reading this AMS5047
\ No newline at end of file
diff --git a/embedded/atkbldcdriver/atkbldcdriver/atkbldcdriver.cproj b/embedded/atkbldcdriver/atkbldcdriver/atkbldcdriver.cproj
index 56c8b18..7327bcc 100644
--- a/embedded/atkbldcdriver/atkbldcdriver/atkbldcdriver.cproj
+++ b/embedded/atkbldcdriver/atkbldcdriver/atkbldcdriver.cproj
@@ -41,7 +41,7 @@
       </framework-data>
     </AsfFrameworkConfig>
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
-    <avrtoolserialnumber>J41800087098</avrtoolserialnumber>
+    <avrtoolserialnumber>J41800086407</avrtoolserialnumber>
     <avrdeviceexpectedsignature>0x1E9842</avrdeviceexpectedsignature>
     <com_atmel_avrdbg_tool_atmelice>
       <ToolOptions>
@@ -51,7 +51,7 @@
         <InterfaceName>PDI</InterfaceName>
       </ToolOptions>
       <ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
-      <ToolNumber>J41800087098</ToolNumber>
+      <ToolNumber>J41800086407</ToolNumber>
       <ToolName>Atmel-ICE</ToolName>
     </com_atmel_avrdbg_tool_atmelice>
     <avrtoolinterface>PDI</avrtoolinterface>
diff --git a/embedded/atkbldcdriver/atkbldcdriver/main.c b/embedded/atkbldcdriver/atkbldcdriver/main.c
index 8d9def3..2669daf 100644
--- a/embedded/atkbldcdriver/atkbldcdriver/main.c
+++ b/embedded/atkbldcdriver/atkbldcdriver/main.c
@@ -183,6 +183,9 @@ int main(void)
 	
 	// start timers for commutation, accel tickers 
 	tickers_init();
+	// startup encoder
+	//encoder_init();
+	
 	// start pwm system
 	pwm_init();
 	// initialize the bldc state structure
@@ -201,6 +204,7 @@ int main(void)
 
 	while (1)
 	{
+		//ams5047_write(&ams5047, 1200);
 		atkport_scan(&atkp0, 2);
 		// just... as fast as we can 
  		tck++;
-- 
GitLab